Skip to main content
Version: 5.x

Show message (MESSAGE, ASK)

The show message operators create actions that show a text message to the user. The message is defined as a property whose value will be used as the message content. This message can be displayed either using a dialog box or in the System.log system window.

Flow control

By default, the created action stops the thread until the user closes the message. However, this behavior can be changed using the corresponding option – in this case, the created action is completed immediately and the message is shown to the user as soon as possible (that is, the next user interaction). The first mode shall be called synchronous and the second asynchronous.

Dialog form

It is also often necessary not only to inform the user about something, but also, for example, to request confirmation to continue an action. For such cases, the operator allows, instead of simply displaying the message (with a single OK button), to ask a question with the option of canceling (OK/Cancel) and thereby essentially to implement a value input. This input is considered to have been canceled if the Cancel button is pressed (there is no input value in that case).

In addition, a third option can be added to the question: Yes / No / Cancel. In this case, it is considered that the input result will be a value of logical class (Yes - TRUE, No - NULL). As in the first case, the input is considered to be canceled if the Cancel button is selected.

The form of the operator in which the user is asked a question shall be called the dialog form.

As with other value input operators, in the dialog form of this operator you can define main and alternative actions. The first is called if the input was successfully completed, the second if not (i.e. if the input was canceled).

The operator dialog form is available in synchronous mode only.

Language

To declare an action showing a message, use the MESSAGE operator. To display the message in dialog form, use the ASK operator.

Examples

message { MESSAGE 'Hello World!'; } // plain text message

isGood = DATA BOOLEAN (Item);
stringData(Item i) {
// depending on which item will be passed to the action, a window will be shown
// either with the text 'Good' or with the text 'Bad'
MESSAGE IF isGood(i) THEN 'Good' ELSE 'Bad';
}

// In this case, five text messages will be shown to the user
testMessage() {
LOCAL i = INTEGER();
i() <- 0;
WHILE i() < 5 DO {
i() <- i() + 1;
MESSAGE i();
}
}

// In the case of NOWAIT, one text message combining messages
// from five MESSAGE calls will be shown to the user
testMessageNowait() {
LOCAL i = INTEGER();
i() <- 0;
WHILE i() < 5 DO {
i() <- i() + 1;
MESSAGE i() NOWAIT;
}
}
testAsk() {
ASK 'Are you sure you want to continue?' DO {
MESSAGE 'You continued';
}

ASK 'Use old values?' useOld = YESNO DO {
IF useOld THEN
MESSAGE 'Using old values';
ELSE
MESSAGE 'Using new values';
}
}