Introduction
FileMaker 15 introduces a major enhancement for the Script Workspace that is a real boon for developers: editing Undo and Redo. This functionality continues the efforts at making the Script Workspace more like a “text editor”. It’s a stress-reducing development enhancement that I think will improve our ability as FileMaker Developers to write scripts.
Undo/Redo gives developers a lot more freedom to experiment with code, without having to carefully manage the editing to avoid trashing existing code. When a refactoring doesn’t work as expected you can simply undo the change and get back to where you were. This new feature will even help you avoid embarrassing situations.
That said, it is helpful to understand exactly how FileMaker has implemented the script Undo/Redo so that you understand the capabilities and limits of the feature. I suggest you fire up FileMaker 15 and explore each of these points, hands on, as you read. Please also take a look at FileMaker’s documentation regarding this new feature.
Undo/Redo for Scripts
- Use standard the command-z (control-z on Windows) shortcut to Undo the last edit.
- Use the standard shift-command-z (shift-control-z on Windows) shortcut to Redo the last Undo.
- Edit history is available for a script as long as the Script Workspace remains open. This behavior seems consistent with the behavior of other text editors (I compared it to Sublime).
- Edit history is available even if you save the script, or switch to another script (again, consistent with Sublime).
- If you close a script or the script workspace as a whole, edit history is lost.
- Each script maintains its own edit history independent of changes in other scripts.
- You can enter script steps by using the type ahead feature or by clicking on the a script step in the list on the right side of the workspace. Each method records the edit in the history, and so makes it available for Undo/Redo.
- History includes script step settings accessed either directly in the script step or in a modal dialog. For example, changes to the on/off setting of the Allow User Abort[on/off] script step is recorded in the history.
- If you enter a script step dialog, such as the one for Show Custom Dialog and then click cancel, no history will be recorded.
- If you enter a script step dialog, make no changes, but then click OK, a history step gets recorded. This means if you make a change, then enter a dialog, then click OK, you would have to Undo twice to get to an actual Undo. This would suggest a development workflow best practice of always canceling a dialog if no changes are made.
- Many script step settings are not visible to the developer while viewing the text of the script. For example, Show Custom Dialog only shows the Title and Message of the dialog, and not the label settings for the buttons or the various check boxes available in the modal dialog. This means that an Undo or Redo operation for a hidden setting provides no feedback to the user as to exactly what happened.
- Undo and Redo are not available when a modal script step dialog is open (ex: the dialog for Show Custom Dialog)
- Undo and Redo are only available when editing the script body and its dependent modal dialogs for editing script step parameters. Script creation and deletion and changes to script order, menu inclusion, and granting of full access are not included in the Undo/Redo history.
- The script history is cleared in a variety of situations, some of which I outlined here. A complete list is found in the documentation. Most notable is that the history gets wiped out if the script is saved by another user!
Undo/Redo for Calculation Dialogs
- History is recorded when you make edits in a calculation dialog. This includes any calculation dialog such as those available in scripts steps, layout objects and field definitions. Once you click OK to commit a change in the calc dialog, you no longer have the ability to Undo or Redo changes made to the calculation. You could of course Undo the change as a whole, just not the individual changes made in the calculation dialog.
- The behavior of Undo and Redo in the calculation dialog for the Watch tab of the Data Viewer (FileMaker Pro Advanced) is different. This makes sense as FileMaker has not yet updated the Data Viewer calculation dialog to reflect the changes made to the calculation dialog in other parts of the development environment. From my testing, it appears that there is no difference in the Undo behavior in the Data Viewer calculation dialog between FileMaker v14 and v15. This appears to be the case with custom function editing as well.
- Undo and Redo history in a calculation dialog is recorded as one change at a time. So, if you are typing characters, each is a separate step in the Undo history. This is a bit of a departure from the behavior of coding text editors such as Sublime that attempt to group sets of characters as a single change with the notion of intelligent code-awareness.
- If you enter a function from the type-ahead feature then the entirety of the function entered is recorded in the history (and so can be undone all at once).
- If you enter a calculation function from the list of functions on the right side of the Script Workspace (by clicking on one), this action is not recorded in the history IF that is the first thing you do. This seems to perhaps be an overlooked implementation detail. It may be best to avoid entering functions in this way and instead use the type-ahead features.
- If however, you type a change, then enter a function from the list, Undo will work. However, it will remove the function you entered and the very last character you typed. Again, best to avoid the list of functions as a means for entering them.
Conclusion: Developer Happiness
The new Undo/Redo functionality in FileMaker 15 is a real boon to developer freedom and efficiency. The advantages of Undo/Redo are only slightly muted by non-visibility of some Undo changes and subtleties of the Edit history, as described here. As long as you understand these limitations, and how FileMaker’s Script Workspace differs from other editing tools and environments, you can leverage this new functionality to help raise the bar on your script code quality, editing efficiency and overall developer happiness.