• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Extending the Interface with ... > Creating Interactive Error Messages

Creating Interactive Error Messages

When a script runs and encounters an error , FileMaker usually displays an error message on the screen. Using the script step Set Error Capture, you can replace this generic statement with a message that not only alerts you to the problem, but provides options for a solution. For this example, we create a message prompt that appears when no records are found by a search script.

To show error messages with customized choices:

1.
Choose Scripts > ScriptMaker. Double-click a script with a Perform Find step in it, or create a new one. Our example is called Find Date (Figure 9.50).

Figure 9.50. This script goes to a layout, enters Find Mode and performs a new search.


2.
In the assembly window, select the script step above the steps you want. In our example, we select the step above the Perform Find step (Figure 9.51).

Figure 9.51. New steps are inserted after the selected step.


3.
From the step list on the left, double-click Set Error Capture. By default, the On option is selected in Options (Figure 9.52).

Figure 9.52. Use Set Error Capture to turn off FileMaker's own messages.


Turning on Error Capture tells FileMaker to take note of the error code for any error that occurs.

4.
While the Set Error Capture step is selected in the assembly window, double-click Loop in the step list on the left.

5.
Click and drag the double arrow to the left of the step to move End Loop to the end of the script (Figure 9.53).

Figure 9.53. Loop will repeat the steps before End Loop.


The Loop step will indent anything you put between it and End Loop so you can easily see that it takes place inside the Loop.

6.
In the assembly window, select the Perform Find step. In the step window on the left, double-click Exit Loop If (Figure 9.54). Click Specify to access the Specify Calculation window.

Figure 9.54. Exit Loop If must occur after the step or steps that might create an error.


7.
In the Specify Calculation dialog box, choose Status Functions in the View drop-down list to access the detailed list of status functions (Figure 9.55).

Figure 9.55. Choose Status to see only the Status functions.


8.
Double-click Status(CurrentError) (Figure 9.56). Click to the right of the formula and type =0 (Figure 9.57). Click OK.

Figure 9.56. Status(CurrentError) looks to see if anything has gone wrong.


Figure 9.57. Status(CurrentError) is 0 if there is no error.


The script is now set to exit the loop if there is no error.

9.
From the Miscellaneous section of the step list on the left, double-click Show Message. In Options, click Specify.

10.
When the Specify Message dialog box appears, type what you want your custom message dialog box to say in the Message Text box.

11.
Double-click in the First (default) box and replace the OK with “Try Again,” or another short phrase that will fit on the button. Leave Cancel in the Second box. Click OK (Figure 9.58).

Figure 9.58. You can customize the message and the buttons that will appear in the error dialog box.


When you create a search that turns up no records matching your Find criteria, your error message will display (Figure 9.59).

Figure 9.59. Your message will appear when a user uses search criteria that don't match the records in the file.


12.
From the step list on the left, double-click If. In Options, click Specify to access the Specify Calculation window.

13.
In the View drop-down list, choose Status functions, then double-click Status(CurrentMessageChoice) (Figure 9.60).

Figure 9.60. Double-click a function to transfer it to the formula box.


14.
Click to the right of the parentheses and type =2. Click OK.

The second message button is Cancel, so this script step says that if you choose Cancel in the dialog box, the If step will end.

15.
From the Sort/Find/Print section of the step list on the left, double-click Show All Records.

16.
From the Navigation section of the step list on the left, double-click Go to Layout.

17.
From the step list on the left, double-click Exit Script (Figure 9.61).

Figure 9.61. If the second button (Cancel) is clicked, the script will exit the loop and return you to the original layout, with all records displayed.


These last three steps say that if you don't choose Cancel, the script will reset the file, return you to the layout, and exit the script so you can try again.

After the End Loop, you can add any commands you want to take place after a successful find.

18.
When you've finished, click OK, then Done.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint