Part of FileMaker Pro's longstanding appeal is its point-and-click interface, but in the area of scripting, we've decided to complement this with new keyboard-driven functionality. This combination of keyboard shortcuts and auto-complete features can dramatically decrease the time it takes you to write your scripts.
This functionality is part of the new Script Workspace, which provides additional efficiency by managing the scripting process in a single window, consisting of the following three panes:
Scripts pane (left)
This pane is for accessing and organizing all the scripts in the solution. This is where you open scripts for editing, run them, or debug them (in FileMaker Pro Advanced). A progressive search box helps you find scripts quickly, and menu management checkboxes determine which scripts appear in the Scripts menu.
Script editing pane (center)
This pane is for viewing and editing specific scripts. The script you are currently editing is displayed in detail, while tabs across the top of the pane allow you to switch to any other script you have open. You can rename a script by double-clicking on its tab. When you want to focus on the script you are writing, you can hide the left and right panes.
As you edit each script, its steps are given different colors based on their syntax. This helps you to scan complex scripts more easily by distinguishing such elements as comments, fields, and script steps that control how the script flows.
Script Steps pane (right)
This pane provides point-and-click functionality for adding steps to your scripts and can also be used as a reference. You can create your own favorites list of the script steps you use the most. If there are script steps you don't know, you can view a brief description of the step at the bottom of the pane, and even click a link to view details in the FileMaker Pro 14 online help.
Let’s start exploring the Script Workspace by creating a simple navigation script.
Explore the three panes of the script workspace, create a simple navigation script starting with point-and-click and then trying the new keyboard functionality, and finally run the script when you're done.
Here is the script you’ll create. It takes the user to one of two layouts depending on whether the current layout is associated with FileMaker Go or FileMaker Pro.
- Choose the Scripts menu > Script Workspace… ⇧⌘S or Shift Ctrl S
The Script Workspace window appears.
Observe how the left pane lists the existing scripts in the solution. The middle pane doesn’t show anything except a script icon because no scripts are being edited. The right pane isn’t displayed yet, because the list of script steps is only necessary when a script is being edited.
Create a script
- Click the + button in the upper left corner of the workspace.
(Note that the "bug" button on the right opens the Script Debugger and is only available in FileMaker Pro Advanced.)
A script named “New Script” appears in the middle pane. Now that a script is being edited, the right pane appears as well.
Currently the cursor is placed in the script name in the tab bar. This is where you give the script its name.
- Change the name to: Go to Contact Details — then press Enter.
Select a script step to view its description
- In the progressive search box on the right pane, type: if
All the script steps that contain the phrase “if” are displayed.
- Select the If script step by clicking it once. A description of the script step appears in the Description box in the lower right of the window.
- Click on the ? button that appears in the upper right of the Description box. A FileMaker Pro 14 Help window appears, displaying a complete description of the If script step.
- Close the FileMaker Pro 14 Help window.
Add two script steps using point-and-click
- Double-click the If script step. Two steps (If and End If) are added to your script in the center pane. Note that they are colored blue because they have to do with script flow. A blinking cursor indicates that FileMaker Pro is waiting for you to enter the condition for the If statement.
- Instead of typing, press Tab to leave the edit box and then click on the “fx” button to the right of the step. A Specify Calculation dialog window appears.
The calculation dialog has also been reorganized to resemble the Script Workspace. Both have three panes, with similar appearance and functionality. Here, the left pane shows tables and fields (note the helpful icons) and includes a progressive search box. The middle pane is used for editing the current expression. The right pane shows available functions, also with progressive search.
You're going to get the name of the current layout using the Get(LayoutName) function. Then you'll use the use the PatternCount() function count the number of times the phrase "| Go" appears in the current layout name. If the pattern appears at least once, the If condition will evaluate as True.
- In the progressive search box of the right-hand pane, type: patt
The function PatternCount ( text, searchString) is displayed, because it is the only one that contains the phrase “patt”.
- Double-click this function to add it to the middle pane.
- Select only the “text” argument within the function.
- In the progressive search of the right-hand pane, type: lay
All the functions whose name contains “lay” are listed. The one you want is Get(LayoutName).
- Double-click this function to replace the “text” argument with Get(LayoutName).
- Replace the “searchString” argument with this expression (including the quotes): “| Go”
The expression should now look like this:
PatternCount ( Get ( LayoutName ) ; "| Go" )
- Click the OK button to save your calculation and dismiss the Specify Calculation dialog window.
- In the progressive search box of the right pane of the Script Workspace, type: lay
All the script steps containing “lay” are listed.
- Double-click “Go To Layout”. The Go to Layout script step is added to your script. It includes a dropdown that lets you specify the layout, which currently is “original layout”.
- Select Layout… from the dropdown. A Specify Layout dialog window appears, including a progressive search box on the right.
- Type the following into the search box: | Go
- Select the “Contact Details | Go” layout (in the Go folder) from the resulting list.
- Click the OK button to save your changes and dismiss the dialog.
Add two script steps using the keyboard functionality
So far this has been reasonably similar to your experience of entering script steps in previous versions of FileMaker Pro. Now let’s try using only the keyboard.
- Press Command-Enter (OS X) or Control-Enter (Windows) to add a script step below the second script step.
- Type: el
The typeahead functionality shows a dropdown list with all script steps that contain this phase. The default step, “Else”, is the one you want.
- Press Enter to select the step from the list.
- Press Command-Enter (OS X) or Control-Enter (Windows) to add a script step below the third script step.
- Type the following acronym (but don't press Enter): gtl
When you type an acronym, all the matching script steps are displayed. In this case, the only match is the Go To Layout script step.
- Press Enter to select the script step.
- Press the Spacebar to enter the script step options. The layout dropdown appears.
- Press the Down Arrow to navigate to the second dropdown item, Layout…
- Press Enter to select this item. A Specify Layout dialog window appears, including a progressive search box on the right.
- Press Tab to move the cursor to the progressive search box.
- Type the following into the search box: | Pro
- Press Tab to move the cursor back to the list of layouts.
- Press the Down Arrow to navigate to the “Contact Details | Pro” layout.
- Press Enter to select the layout and dismiss the dialog window. This is the same as clicking the OK button. If you wanted to cancel, you would press Esc.
The Go to Layout script step in the center pane is updated to display the options that you entered.
Save and run the script
Observe that an asterisk appears next to the name of your script in the tab at the top of the center pane. This means that the script has unsaved changes.
- Press Command-S (OS X) or Control-S (Windows) to save the script. The asterisk disappears to indicate that the script was saved.
- Make sure you are viewing the “Contact List | Pro” layout (in the Pro folder).
- Click the Run button near the upper left corner of the Script Workspace.
Because you started on a “Pro” layout, the script takes you to the “Contact Detail | Pro” layout.
Close the script
- Hover over the tab displaying the script’s name at the top of the middle pane. An X button appears on the right of the tab while you hover over it.
- Click the X button to close the script. You can also type Command-W (OS X) or Control+W (Windows).
Note that closing the Script Workspace does not close any scripts that you have open. This can be convenient if you want to close the window for a moment, but return to your work later. However, you will be prompted to save any scripts that you have modified.
Scripting Keyboard Shortcuts
Tip: Check out the Scripts menu
Two commands are now only available from the Scripts menu. Both of these are available in FileMaker Pro Advanced only:
- Import... (for importing scripts from other files)
- Grant Full Access Privileges (for changing the access privileges of a user while a specific script is running)