Controlling Scripts with User Input
You can use the Show Custom Dialog script step to prompt a user entry to control a script. The message text you enter will be displayed in a dialog box.Using the Print Invoices script, we can add a step that checks whether there is an Invoice Date and, if there is, asks you if you want to print the invoice anyway. This will prevent unintentional duplicate invoices. You can include If steps within other If steps (nested Ifs). Just as steps in an If are run only when the preceding If is true, a nested If is evaluated only when the first If is true.If the user chooses the Print button, the script will execute the rest of the steps. If the user chooses Don't Print, the script will stop.
To control scripts with user input
1 .Choose Scripts > ScriptMaker (Control+Shift+S/Command+Shift+S). When the Define Scripts dialog box appears, click New.2 .In the Define Scripts dialog box, click the script to which you want to add user controls. In our case, it's the Print Invoices script. Click the Duplicate button, then click Edit. This keeps your original script intact, which can be very useful if you make a mistake as you edit.3 .When the Edit Script dialog box appears, give the script a slightly different name. Click the second Set Field step in the script-assembly list.4 .In the step window on the left, click Else (Figure 8.45).
Figure 8.45. Select the step before the one you want to insert.
[View full size image]

Figure 8.46. Show Custom Dialog is used to display text and get input from the user.

Figure 8.47. You can enter text to create a customized message and set of buttons. OK and Cancel are the default choices, but you can replace them with custom text.
[View full size image]

Figure 8.48. Designate your message choices in the "Show Custom Dialog" Options dialog box.

Figure 8.49. This custom dialog box will display when you run the script.

Figure 8.50. If the user clicks the second button, Get(LastMessageChoice) will equal 2.

Figure 8.51. The "2" in this step refers to the second button choice in the dialog box.

