Skip to main content
MedCalc
Mail a PDF copy of this page to:
(Your email address will not be added to a mailing list)
working
Show menu

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:

CANCEL0
OK1
YES1
NO2

Example:

a=Alert("Continue?",YESNO);

shows:

Script generated message box.

When Yes is clicked then the variable a contains 1; when No 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:

The dialog box is displayed with the Dialog() function. The Dialog() function takes no parameters and returns 1 when OK was clicked or 0 when Cancel was clicked.

When the dialog box is closed, and OK 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:

Script generated dialog box.

When the dialog box is completed as follows:

Script generated dialog box.

then, when OK is clicked:

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:

Example:

m=Input("Enter a percentage: ",PERCENTAGE);
?m;

This creates the following dialog box:

Script input box.

In the example, 5 is entered in the dialog box, and when OK is clicked, the variable m contains the value 5.

See also