Scripter contains a dialog editor that you can use to design customized dialogs for use with automation. Select the Edit | UserDialog Editor command to visually design a dialog. You can control the size and placement of the components of the dialog, as well as customize the text included in the dialog.
Adding Items to the Dialog
To add a component to a dialog, first select from the palette of components at the left side of the dialog editor. After clicking a palette button, drag the mouse pointer diagonally in the dialog design area where you want to place the component. As you design the dialog, you can edit the properties of components you have placed in the dialog. To edit the properties of a component, double-click the item, click the right mouse button on the item, or select the component and click the button. Every dialog must include an OKButton or a CancelButton, or both.
Saving a Dialog
When you have finished designing the dialog, click the button. The code for the dialog is inserted into the script.
Editing a Dialog
To edit the dialog template after it has been inserted into the script, first move the cursor in the code window to any line between the BEGIN DIALOG statement and the END DIALOG statement. Next, select the Edit | UserDialog Editor command. The previously saved state of the dialog is shown in the dialog editor. When you save the dialog again, the previous dialog template is replaced with your changes.
Displaying the Dialog
To show your custom dialog in a script, first use the DIM statement to declare a variable as the UserDialog type, and then call the DIALOG function to display the dialog (see the example). The DIALOG function takes a user dialog variable as its argument and returns a number indicating which button was clicked to end the dialog. The DIALOG function returns -1 if the OK button was clicked, 0 if the cancel button was clicked, or an integer greater than zero if a push button was clicked (1 for the first push button listed in the dialog template, 2 for the second push button in the dialog template, and so forth).
If the return value is not needed, the DIALOG instruction may be called as a subroutine rather than as a function. In this case, do not enclose the dialog variable in parentheses. If the DIALOG instruction is called as a subroutine, however, the script ends with a run-time error if a cancel button is clicked.
Creating Multiple Custom Dialogs
To define more than one custom dialog in a script, you must place each dialog template in its own subroutine or function. If you try to define more than one custom dialog in the same procedure, Scripter shows an error indicating that the UserDialog type has already been defined.
Values in Dialogs
The values contained by dialog controls are accessed the same the way the fields of user-defined variable types are accessed. Type the dialog variable name, followed by a period, followed by the field name of the dialog component. Option button values cannot be accessed directly, but are accessed via the field name of their associated option group. The value of an OptionGroup is the number of the selected option button (the first option button in the group is 0, the second option button is 1, and so forth). You can initialize the values contained by dialog controls prior to showing the dialog, and retrieve the values entered in the dialog after it has been invoked.
See Also