MsgBox
MsgBox(msg, buttons, title)
MsgBox displays a standard popup modal dialog box with a user-supplied message «msg» when it is evaluated. It pauses evaluation until the user presses a button on the message box. If the user presses Cancel, it stops further computation.
By default, the message box will show buttons OK and Cancel, and title of the dialog is the identifier of the Variable (or Function) that calls MsgBox().
You can use MsgBox to show the model user a message, warning, or error during evaluation. A common use is for model debugging to show intermediate values while a complex algorithm is in progress.
Declaration
- MsgBox(message ; buttons: optional scalar; title: optional text)
Example
Variable Profit := Array(Time, [-121.1M, -75.33M, -12.41M, 62.06M, 62.06M, 1.594M, -58.87M, -119.3M])
MsgBox(Profit) →
Optional parameters
Buttons
The optional «buttons» parameter can be used to control which buttons are displayed, as follows:
0
= OK only1
= OK and Cancel [Default]2
= Abort, Retry and Ignore3
= Yes, No and Cancel4
= Yes and No5
= Retry and Cancel
The icon can also be changed by adding the following to the buttons parameter:
16
= Critical32
= Question48
= Exclamation64
= Information
The return value indicates which button was pressed, as follows:
1
= OK2
= Cancel3
= Abort4
= Retry5
= Ignore6
= Yes7
= No
In ADE, MsgBox displays nothing and returns 0
.
If a user presses Cancel, the current computation aborts.
Title
The optional «title» parameter can be used to provide a title for the message box . If no title is specified, the title defaults to the title of the calling variable or function.
Details and more examples
MsgBox does not array abstract over its first parameter. Instead, it attempts to display the entire parameter using the current tableType system variable format with the number format of the variable containing the call. Atomic text strings or numbers appear as such, but arrays appear in a format such as:
Array(Time, [-121.1M, -75.33M, -12.41M, 62.06M, 62.06M, 1.594M, -58.87M, -119.3M])
Example: This example provides a peek at the result before returning it.
var v := Sales_revenue - Cost;
MsgBox(v);
v
Enable comment auto-refresher