FileMaker Extra: Creating a Script Library
FileMaker Extra Creating a Script Library
You might consider having a utility file sitting around your hard drive with all the basic scripts each of your solutions will need. You can then import these scripts into your own solution files as needed. We always have the following in our databases:
- Relogin This script should be the first you have in every file. Press (
-1) [Ctrl+1] (if it's turned on in the menu) and you'll be able to log in again and test how things work for your end users. This is a critically useful script to have access to during development and testing. - StartUp Here's a script we use to open all the files of a given solution at once, to set default values for globals, to set a login history record if need be, and so on.
- ShutDown The partner for StartUp, the ShutDown script can close out your user session by setting any tracking info and can close all the files in a solution so that FileMaker Pro need not be quit.
- ToggleAllStatusAreas This is another critical script for developers working in multiple files or windows. Very often we'll close and lock the Status Area to maintain control and keep users from accessing records or layouts we have carefully scripted around. This handy script reopens the Status Area for development.
- ToggleMultiUser A script that simply turns on or off peer-to-peer sharing. It is useful to use the Set Multi-User [on/off] script step when you need to isolate your system during testing.
- InitializeGlobals Often a subscript of StartUp, but best abstracted as it is here, this script sets all the initial values of globals and global variables in your system, ensuring that they all start out user sessions in a predictable state. You need to add explicit steps for each global you add to your system as you work, but you'll find it invaluable to have a "global" global initializer.
- ScriptTEMPLATE This is the template we duplicate for new scripts. It has initial comment headers and default script steps as needed.
- - Okay, maybe it only saves you a single keystroke, but having an already-ready hyphen handy just means a quick click on the duplicate button. (And a nice touch from the engineers at FileMaker: Since FileMaker Pro 7, hyphens simply duplicate and don't get suffixed with a "copy"!)
- PrintSetUp_landscape and PrintSetUp_portrait Every printer-bound output of your system needs page properties established. Write them once.
- ___ScriptHEADER_________________ Here's an empty script for dividing your script menu into logical subsections. Again, clicking the Duplicate button means you don't need to count how many underscores to use.
If you find yourself writing certain scripts time and time again, add them to your library. Using the capability in FileMaker Pro 8 Advanced to copy and paste scripts enables you to more easily leverage prior work.