MESSAGEBOX_ASYNC

The MESSAGEBOX_ASYNC function is identical to the MESSAGEBOX function, except that it does not wait for a response, but allows XJEase code execution to continue. The selected button is returned as a keyboard character, whose value is the same as the return values for the MESSAGEBOX function.

MESSAGEBOX_ASYNC was added in XJTAG v2.6.

Syntax

MESSAGEBOX_ASYNC( 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 (see the table in the MESSAGEBOX help).
buttons
An integer value indicating which buttons to display in the dialog (see the table in the MESSAGEBOX help).
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

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.

Example

This example test function prompts the user asynchronously to validate that an LED is flashing, so that the code can continue running and flash the LED.

GLOBAL Test()(INT result)
  INT key;
  STRING question := "Is LED " + UNIQUE_DEVICE_REF + " toggling red and green?";

  // Display the message box, but continue execution
  MESSAGEBOX_ASYNC(question, "LED " + UNIQUE_DEVICE_REF, MB_ICON_QUESTION, MB_BUTTONS_YES_NO);

  DO 
    SetLED(RED);
    SLEEP(100);
    SetLED(GREEN);
    SLEEP(100);

    // GETKEY will return a non-zero value once the user has pressed a button
    key := GETKEY();
  WHILE key = 0
  END;

  IF key = MB_BUTTON_YES THEN
    result := RESULT_PASS;
  ELSE
    result := RESULT_FAIL;
  END;
END;