New in 14: Script Workspace

Version 2

     

     

     

    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:


     

    571-script+workspace+panes.png



    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.


    572-script+workspace+left+v2.png

     

     

    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.

    573-script+workspace+center+v2.png


    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.


    574-script+workspace+right+v2.png

     

     

    Let’s start exploring the Script Workspace by creating a simple navigation script.


     


     

     

    Goal:

     

    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.



    The script:

     

    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.

    575-pasted-image-21.png

     

    Steps:

     

    1. 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

    2. Click the + button in the upper left corner of the workspace.
      576-pasted-image-22.png
      (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.

    3. Change the name to: Go to Contact Details  —  then press Enter.


      Select a script step to view its description


    1. In the progressive search box on the right pane, type: if

      All the script steps that contain the phrase “if” are displayed.

    2. 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.

    3. 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.

    4. Close the FileMaker Pro 14 Help window.


      Add two script steps using point-and-click

    5. 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.

    6. 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.
      577-pasted-image-23.png
      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.

    7. 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”.

    8. Double-click this function to add it to the middle pane.

    9. Select only the “text” argument within the function.

    10. 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).


    11. Double-click this function to replace the “text” argument with Get(LayoutName).

    12. Replace the “searchString” argument with this expression (including the quotes):  “| Go”

      The expression should now look like this:
      PatternCount ( Get ( LayoutName ) ; "| Go" )

    13. Click the OK button to save your calculation and dismiss the Specify Calculation dialog window.

    14. In the progressive search box of the right pane of the Script Workspace, type: lay

      All the script steps containing “lay” are listed.

    15. 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”.

    16. Select Layout… from the dropdown. A Specify Layout dialog window appears, including a progressive search box on the right.

    17. Type the following into the search box:  | Go

    18. Select the “Contact Details | Go” layout (in the Go folder) from the resulting list.

    19. 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.

    20. Press Command-Enter (OS X) or Control-Enter (Windows) to add a script step below the second script step.

    21. 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.


    22. Press Enter to select the step from the list.

    23. Press Command-Enter (OS X) or Control-Enter (Windows) to add a script step below the third script step.

    24. 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.


    25. Press Enter to select the script step.

    26. Press the Spacebar to enter the script step options. The layout dropdown appears.

    27. Press the Down Arrow to navigate to the second dropdown item, Layout…

    28. Press Enter to select this item. A Specify Layout dialog window appears, including a progressive search box on the right.

    29. Press Tab to move the cursor to the progressive search box.

    30. Type the following into the search box:  | Pro

    31. Press Tab to move the cursor back to the list of layouts.

    32. Press the Down Arrow to navigate to the “Contact Details | Pro” layout.

    33. 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.

    34. Press Command-S (OS X) or Control-S (Windows) to save the script. The asterisk disappears to indicate that the script was saved.

    35. Make sure you are viewing the “Contact List | Pro” layout (in the Pro folder).

    36. Click the Run button near the upper left corner of the Script Workspace.
      578-pasted-image-24.png

      Because you started on a “Pro” layout, the script takes you to the “Contact Detail | Pro” layout.


      Close the script

    37. 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.
      579-close+a+script.png

    38. 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

    We recommend that you take the time to become proficient with the new keyboard functionality. A complete list of scripting keyboard shortcuts are available online for both OS X and Windows.

     

     

    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)