Automating repetitive tasks is always helpful, particularly if they involve several steps that would keep you glued to the screen instead of doing something productive. Although you can wade through FileMaker's startup screens and dialog boxes, it's more efficient to create a single startup script to open several multiuser files automatically.
To create an opening script
1 .Start FileMaker. When the Open File dialog box appears, click Cancel. Choose File > New Database.2 .When the "Create a new file named:" dialog box appears, give the new database a descriptive name like NetStart (Figure 16.3). Click Save.
Figure 16.3. You can create a new database that only opens files from the network.
When the Define Database dialog box appears, just click OK.3 .Choose File > Open Remote (Control+Shift+O/Command+Shift+O).4 .When the Open Remote File dialog box appears, click the host computer and make sure that all of the databases you want the script to open are available on the network (Figure 16.4). Open them on the host computer if they're not already open. To close the dialog box, click Cancel.
Figure 16.4. All the files you want to open over a network must be available before you create the script.
5 .Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S). In the Define Scripts dialog box, click New. In the Edit Script dialog box, type a name for the script (ours is Opener).6 .In the script step list on the left, scroll down to Files and double-click Open File (Figure 16.5).
Figure 16.5. The Open File step can open files from the host.
7 .In the Script Step Options section, click the Specify drop-down list and choose Add File Reference. When the Open File dialog box appears, click Remote (Figure 16.6). In the Open Remote File dialog box, double-click to choose the file from Available Files list (Figure 16.7).
Figure 16.6. Specify the file you want to open by adding a file reference.
Figure 16.7. In the Open Remote File dialog box, select files for the script to open.
8 .In the script step list on the left, scroll up to the Control section and double-click Set Error Capture On, then double-click If.By turning on Error Capture, you suppress unnecessary error message dialog boxes.9 .In the Script Step Options section, click the Specify button to bring up the Specify Calculation dialog box.10 .Click the View drop-down menu on the right and choose "Get functions." In the Get functions list, double-click the Get(LastError) function.11 .Click to the right of the parentheses. In the Operators list, double-click ¤. Type 0 to the right of the equals sign (Figure 16.8). Click OK to return to the Edit Script dialog box.
Figure 16.8. Get(LastError) will return 0 if the specified file is found on the network.
12 .In the script step list on the left, scroll down to Files and double-click Open File. Leave the option set to <unknown>.This If statement specifies that if FileMaker generates an error, the Open File dialog box will appear so you can manually locate the file.13 .If there are other files you want this script to open, you can duplicate this first group of steps and edit them. Click the first step, hold the Shift key, and click the last step to select the group. Click the Duplicate button (Figure 16.9).
Figure 16.9. Select multiple steps by holding down the Shift key while selecting.
14 .Double-click the first new Open File step. Click the Specify drop-down list and choose Add File Reference. Click Remote and choose the next file you want the script to open.15 .Repeat steps 13 and 14 for as many other files as you need to open at startup.16 .Select the End If step in the right window. In the step list on the left, scroll to the Files section and double-click Close File (Figure 16.10). Leave the Script Step Options set to Current File.
Figure 16.10. The Close step will close any open file you specify.
The Close step closes the file you just created. If you aren't sure how the script will work, you can omit this Close script step so you can more easily return to the script to make changes.17 .Click OK twice to finish.18 .Choose File > File Options. The File Options dialog box will appear with the Open/Close tab selected. In the "When opening this file" section, click "Perform script." From the script drop-down menu, choose the script you just created (Figure 16.11). Click OK.
Figure 16.11. Set the script to run on startup in the File> File Options settings.
Copy the file to each client machine. When you want to open your network files, double-click to launch the database you just created. The script will run automatically, opening the specified files and then closing itself. If you open a database that has related files, the related files will open automatically, too. TipIf you include the Close step but discover when the script runs that you need to change it, press Escape (Windows) or Command+period (Macintosh) repeatedly as the database opens. This will cancel the script and leave the file open so you can access ScriptMaker (Control+Shift+S/ Command+Shift+S). If you think this might happen frequently, you can give yourself enough time to cancel the script by inserting a short pause in the script itself.