MESSAGEBOX

The MESSAGEBOX function is used to display a dialog box to the user and wait for a response.

In XJRunner a modal dialog is displayed:

Example message box in XJRunner

When multiple XJLinks are in use, XJRunner will direct the user's attention to any tab that is trying to display a dialog box, but will not display the dialog until the tab is selected. The behaviour is very similar to the ALERT statement.

In XJRun a simple prompt is displayed:

Example message box on the command line

All the values used by MESSAGEBOX are defined as constants in the standard Globals.xje circuit code file that is added to all new projects. If your copy does not contain the constants, it can be updated.

Syntax

MESSAGEBOX( STRING message, STRING title, INT icon, INT buttons [ , STRING imageFilename ])

Parameters

message
The text to display as in the dialog box.
title
The text to display as the title of the dialog box.
icon

An integer value indicating which icon to display in the dialog box.

Value Description Icon Constant
0 No icon   MB_ICON_NONE
1 Error MB_ICON_ERROR
2 Question MB_ICON_QUESTION
3 Warning MB_ICON_WARNING
4 Information MB_ICON_INFORMATION
buttons

An integer value indicating which buttons to display in the dialog.

Value Buttons displayed Constant
0 OK MB_BUTTONS_OK
1 OK, Cancel MB_BUTTONS_OK_CANCEL
2 Abort, Retry, Ignore MB_BUTTONS_ABORT_RETRY_IGNORE
3 Yes, No, Cancel MB_BUTTONS_YES_NO_CANCEL
4 Yes, No MB_BUTTONS_YES_NO
5 Retry, Cancel MB_BUTTONS_RETRY_CANCEL
imageFilename

This parameter is optional.

The filename of an image which is to be displayed in the dialog. When running from an XJPack file, this will first look the in XJPack file for the image and then on file system. See how files are located for more information on how the path is resolved. If the parameter is omitted or is an empty string, then no image will be displayed. Supported file types are:

  • BMP
  • GIF
  • JPEG
  • PNG
  • TIFF
Example message box with image

Note that if a relative path is used, then images may need to be added as additional files when creating the XJPack file for them to be accessible when running from the XJPack file.

Return value

An INT value indicating which buttons was pressed.

Value Button pressed Constant
1 OK MB_BUTTON_OK
2 Cancel MB_BUTTON_CANCEL
3 Abort MB_BUTTON_ABORT
4 Retry MB_BUTTON_RETRY
5 Ignore MB_BUTTON_IGNORE
6 Yes MB_BUTTON_YES
7 No MB_BUTTON_NO

Example

INT result;
result := MESSAGEBOX("Do you want to continue?", "Test Failure", MB_ICON_QUESTION, MB_BUTTONS_YES_NO);
IF result = MB_BUTTON_YES THEN
  PRINT("Continuing\n");
ELSE
  PRINT("Stopping\n");
  RETURN;
END;