Scripts - Dialogs
Alert
Alert(message[,buttons]) generates a message on the screen. The optional parameter buttons can be OK, OKCANCEL, YESNO or YESNOCANCEL. The function returns a value corresponding with the button clicked on:
CANCEL | 0 |
OK | 1 |
YES | 1 |
NO | 2 |
Example:
a=Alert("Continue?",YESNO);
shows:
When
is clicked then the variable a contains 1; when is clicked, a contains 2.Custom dialogs
A script can define a custom dialog between <dialog> and </dialog> tags.
Each row in the <dialog> </dialog> block consists of a system variable followed by a description.
The following can be included:
- $dlgvar1, $dlgvar2, $dlgvar3, $dlgvar4: includes a variable selector in the dialog box
- $dlgfilter: includes a filter selector in the dialog box
- $covariates: includes a covariates selector in the dialog box
- $option1, $option2, option3, $option4, $option5: includes options in the dialog box
- $input, $input2, $input3, $input4: includes input fields in the dialog box
The dialog box is displayed with the Dialog() function. The Dialog() function takes no parameters and returns 1 when was clicked or 0 when was clicked.
When the dialog box is closed, and
was clicked, the corresponding system variables contain the selections made in the dialog box.Example:
<dialog> $dlgvar1 Select a variable $dlgvar2 Select a variable $dlgfilter Filter $option1 Log transformation $input1 Enter the test value </dialog> m=Dialog();
This creates the following dialog box:
When the dialog box is completed as follows:
then, when
is clicked:- the variable m contains the result of the Dialog() function, 1 (when is clicked, m is 0)
- the system variable $dlgvar1 will contain the string "Height", and $dlgvar2 will contain "Weight"
- $dlgfilter will contain "group='a'"
- $option1 will be 1
- $input1 will be 25.6.
Input
Input(message,type) is a function that creates a dialog box for a single input. The function returns the value entered in the dialog box.
The parameter type can be:
- TEXT
- INTEGER
- REAL
- PERCENTAGE
- DATE
- TIME
Example:
m=Input("Enter a percentage: ",PERCENTAGE); ?m;
This creates the following dialog box:
In the example, 5 is entered in the dialog box, and when
is clicked, the variable m contains the value 5.