Some errors are classics: They crop up in every new scripter's efforts and are all very easily fixed. Before you try troubleshooting your scripts from scratch, check this group of suggested problems and their solutions.
1 .If the troublesome script is supposed to find a certain set of records, choose Scripts > ScriptMaker (Control+Shift+S/ Command+Shift+S).
2 .In the Define Scripts dialog box, double-click the script you want to check.
3 .When the Edit Script dialog box appears, double-click the Perform Find step in the script-assembly list.
4 .
When the Specify Find Requests dialog box appears, double-click to select the Find Request for the script you are running (Figure 10.3).
5 .When the Edit Find Request dialog box appears, check the Action drop-down list to verify that the right selectionFind Records or Omit Recordswas selected (Figure 10.4).
6 .Highlight the Find Request to see the Find criteria last used by the script. Make the necessary changes in the "Find records when:" and Criteria sections. Click OK four times to finish.
1 .If your script has any Find steps, make sure you follow the steps in the previous section "To fix missing or wrong records."
2 .
Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S).
3 .In the Define Scripts dialog box, double-click the script you want to check.
4 .When the Edit Script dialog box appears, double-click the SortRecords step in the script-assembly list.
5 .
When the Sort Records dialog box appears, check that the table occurrence in the drop-down list on the left is correct. Change the sort fields and their order as needed (Figure 10.5). Click OK three times to finish.
1 .Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S).
2 .In the Define Scripts dialog box, double-click the script you want to check.
3 .
When the Edit Script dialog box appears, double-click the Print or Print Setup steps in the script-assembly list. When the Print or Print Setup dialog box appears, change the format as needed. Click OK.
4 .In the Script Step Options section, uncheck "Perform without dialog" if it is checked (Figure 10.6).
5 .Click OK, then click Perform to check the script. If the correct print settings appear, double-click the script again. In the Edit Script dialog box, select the Print or Print Setup script step you changed, and recheck "Perform without dialog." Click OK twice to finish.
1 .Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S).
2 .In the Define Scripts dialog box, double-click the script.
3 .When the Edit Script dialog box appears, highlight the last script step in the script-assembly list (Figure 10.7).
4 .
In the Navigation section of the step list on the left, double-click Go to Layout.
5 .
In Script Step Options, choose the layout you want the script to end on from the Specify drop-down menu (Figure 10.8). Click OK three times to finish.
If you end a script with a sub-script, the sub-script, in effect, becomes the main script. This can be confusing if the sub-script calls information from another file, because it can leave you in the external file if that file contains the last selected window. The solution is simple: Add a Navigation script step to the end of the main script. We recommend Go to Layout, using the default option of "original layout," to end up in the same layout you were in before you ran the script.
1 .Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S).
2 .In the Define Scripts dialog box, double-click the script.
3 .When the Edit Script dialog box appears, look for a Go to Record/Request/Page step. If you see one, click to select it.
4 .
Under Script Step Options, check the "Exit after last" check box (Figure 10.9). Click OK, twice to finish.
5 .If you have no Go to Record/Request/Page step, look for an Exit Loop If step. If you don't find one, click to select the step above the End Loop step (Figure 10.10).
6 .In the step list on the left, double-click Exit Loop If.
7 .Under Script Step Options, click Specify to bring up the Specify Calculation dialog box and specify the circumstances under which you want the script to end. Click OK three times to finish.
In our example, we have the loop exit when the counter is greater than 10 (Figure 10.11).
The Allow User Abort script step (Figure 10.12) controls whether you can cancel a running script. When you're creating and testing scripts that contain loops, add it as the first line of your script and set its option to On. When the script runs, you can stop it by pressing Escape (Windows) or Command+period (Macintosh). If you have sub-scripts in your script that call steps you might want to cancel, you'll need to place an Allow User Abort step in them and turn it on as well.
You can cause yourself problems if you cancel a script before it finishes. Caught in mid-stream, an unfinished script leaves an inconsistent database with some records processed and some untouched. To avoid creating problems instead of solving them, remember to turn the Allow User Abort option to Off after you've finished troubleshooting. Otherwise, if your script has a step in it that already includes a pause for input (like a Find request), a Cancel button will appear in the status area and someone could click Cancel instead of Continue (Figure 10.13).