Script Cmd: DIALOG
DIALOG [h:mt:w:x:y:] {dialog type} {"user message string"} ["q_and_a default answer"]
This command allows the script to interact with the user through some type of dialog box.
Options:
-h {##} | override default height of dialog box created. | |
-m | create dialog box in "modeless" mode (more details below) | |
-r {name} | override default use of DIALOG as shell variable to store the result | |
-t {##} | override the default text in the title bar of the dialog box created. | |
-w {##} | override default width of dialog box created. | |
-x {##} | override left edge position for new dialog box. | |
-y {##} | override top edge position for new dialog box. |
Valid dialog types:
* indicate special case (see below)
This gives the script the ability to specify a type of message box and a message. The box will then be presented to the user and the user will have to click a button (OK or YES or ABORT etc..) depending on the type of message box selected. Then the content of the shell variable DIALOG will contain the string that corresponds to that button... If the "YES" button was hit, then $DIALOG would contain "YES", if the "CANCEL" button was hit, then $DIALOG would contain "CANCEL" (and so on..).
Note: if the user message string contains a "\n" (backslash n), that will be interpreted to mean that the user wants to insert a newline into the text displayed on the dialog. For large blocks of text, the shell variable(s) DIALOG_LX (where 1 <= X <= 100) can be preloaded with the text to be put in the dialog box. When the DIALOG command runs, if it detects the presence of the DIALOG_L1 variable, that text will be used in place of the text on the command line. For example...
Special cases (not just button selections):
By default, the dialog box is a "modal" dialog box. This means that the user must complete the dialog interaction prior to doing anything else within uCon. The -m option allows the dialog box to be created in modeless mode; hence the user now has the ability (if -m is used) to transition to other uCon facilities prior to completing the interaction with the dialog box. Note that the -m option is applicable to the following dialog types:
OK, ABORT_RETRY_IGNORE, OK_CANCEL, RETRY_CANCEL, YES_NO and YES_NO_CANCEL.
Note that each of the dialog boxes provides the option to close (upper right corner button). If the dialog box's close button is clicked, the script is terminated at the line that generated the dialog box.
Following are a few of the generated message boxes...
The script line...
will generate the dialog box...
The content of $DIALOG after this will always be "OK".
The script line...
will generate the dialog box...
If the Yes button is clicked, then $DIALOG will contain "YES". If the No button is clicked, then $DIALOG will contain "NO".
The script line...
will generate the dialog box...
If the OK button is clicked, then $DIALOG will contain "OK". If the CANCEL button is clicked, then $DIALOG will contain "CANCEL".
The script line...
will generate the dialog box...
After clicking the continue button, $DIALOG will contain whatever was typed in the editbox. It is important to note that since there may be whitespace in the text returned to $DIALOG, it should be wrapped with double quotes (i.e. "$DIALOG") to still be seen as a single command line argument.
Note that this dialog sub-command allows the user to specify a default answer by putting an additional argument on the command line.
The script line...
will generate the dialog box...
After clicking OK, $DIALOG will contain whatever text was in the selected item. Similar to the Q_AND_A dialog above, it is important to note that since there may be whitespace in the text returned to $DIALOG, it should be wrapped with double quotes (i.e. "$DIALOG") to still be seen as a single command line argument.
The script line...
DIALOG GET_FILE "Enter filename:" "default_filename"will generate the dialog box...
Note: The optional "q_and_a default answer" argument on the command line is only applicable to the "Q_AND_A" dialog type. It is used to pre-load some string into the editbox of the Q_AND_A dialog.
The $DIALOG variable will contain whatever the user types into the text box in the dialog. The user is required to type something. If the box is empty when the button is clicked, an error dialog will be generated to let the user know that something must be entered.
Refer to EXAMPLE_3 on the main scripting page for a working example of the DIALOG command.