uCon HomePage

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:

- OK
- YES_NO
- DDLIST *
- GET_FILE *
- Q_AND_A *
- PQ_AND_A *

- OK_CANCEL
- RETRY_CANCEL
- YES_NO_CANCEL
- ABORT_RETRY_IGNORE

* 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...

SET DIALOG_L1 "This is some text for the dialog box.\n"
SET DIALOG_L2 "We use the DIALOG_LX variables here because of the amount of text.\n"
SET DIALOG_L3 "Click OK when you're happy."
DIALOG -t LOAD_SPI_MODE7 -w 300 -h 120 OK ""

Special cases (not just button selections):

- Q_AND_A {question} [default_answer]
The command argument provides a question and the user provides the answer. Whatever is in the answer becomes the content of the DIALOG shell variable. The script can then use the IF statement to process the result of the interaction.

- PQ_AND_A {question} 
This
is similar to Q_AND_A except that the text is displayed as asterisks to maintain some level of privacy, specifying a default answer is not an option.  Plus, if -r option is used with this command, then the variable is created and the hidden attribute is applied.

- GET_FILE {text} {default-filename}
The command argument provides the default filename then allows the user to accept that, enter a new one or browse for a filename using the standard FileOpen mechanism in windows. The DIALOG shell variable will contain the filename.

- DDLIST {question} {drop-down-item 1} [item2] [item3] ...  (max of 28)
The command argument provides the question and a list of possible choices, each of which will be clickable through a drop-down list. The DIALOG shell variable will then contain the text of the selected item.

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...

DIALOG OK "Continue?"

will generate the dialog box...

The content of $DIALOG after this will always be "OK".


The script line...

DIALOG YES_NO "Are you a republican?"

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...

DIALOG OK_CANCEL "Ok to continue or cancel now?"

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...

DIALOG Q_AND_A "Enter a number between 1 and 5:"

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...

DIALOG DDLIST "What do you want to do?" "buy a car" "build a house" "rob a bank"

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...


The user can simply type in the filename or use the system browser to select a file that already exists.  After clicking Continue, $DIALOG will contain whatever text was text box.  Again, 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.

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.