Creating Script Templates Using ScriptBuildingBlocks
04/24/2010 - I recently tried out Tony White's excellent ScriptBuildingBlocks tool for FileMaker, and was immediately hooked on the new abilities it offers to FileMaker developers working on the Mac platform.
ScriptBuildingBlocks is a tool from Tony White Designs that allows its users to instantly insert sets of script steps into the FileMaker script editor. The utility comes with 14 prebuilt templates, and I quickly learned how to add my own and to edit the existing templates. Included in the SBB set are shortcuts for creating script steps for common structures like IF-ELSE IF-ELSE-END IF, LOOP-END LOOP, LOOP PORTAL-END LOOP, set variable to get(scriptParameter), adding comments, a date-stamped comment, and others.
To use ScriptBuildingBlocks, you will need to be working on a Mac; it works with FileMaker 9, 10 and 11, and requires Quickeys 4. As a user of Quickeys since 1987 when it was introduced, I rely on it every day. Besides its great use for this FileMaker utility, you will find many other uses for Quickeys, and I highly recommend it to anyone using a Mac.
Installation of SBB was simple; once you've copied the scripts folder to two locations, and copied the toolbar to a third folder, you can restart Quickeys and immediately use SBB. When you're in the Script Editor and you've clicked inside the script step pane, you can click any of the buttons in the toolbar to immediately insert the script steps into your script.
Each of SBB's shortcuts consists of two files: an AppleScript file, which is read-only, and a text file containing XML. It is this second file that can be edited or cloned to create some really useful shortcuts.
I wanted to add some of my own favorite code snippets, so I copied existing pairs of shortcuts to make my own. Tony White has done the heavy lifting for you by creating some nice examples and by creating the companion AppleScript for each, so with a little experimentation you can come up with some great shortcuts.
Once I saw that SBB was working, I immediately dived into the simple scripts to make my own templates. Here's an example of a few script steps:

In this example I"m setting 6 script steps, all of which are COMMENT steps. As you can see, the first and last steps add a comment with no text, and the other four add comment steps with my own comments in them.
Here's an example of an IF/END IF statement:

In this example, the shortcut creates 2 script steps: an IF that says, "if x = 1," and an END IF.
Once you've cloned a pair of files (one SCPT(AppleScript) file and one TXT file), the next step is to add your new shortcut to the SBB palette.
In Quickeys, you can copy an existing shortcut, and then paste to create a clone of it; once you've done that, it's short work to edit the shortcut to trigger your newly-created script template. In the AppleScript step of the shortcut, point the shortcut to your new file; if you want, you can create and install your own icon, which will show up in the toolbar; the icons are 16 x 16 and you can copy and paste them right into the Quickeys editor.
Once that's done, simply drag your new shortcut into the toolbar; that's it!
You can find Tony White’s excellent ScriptBuildingBlocks utility here.