Intouch Script Function Sample of MessageBox

Description

This function displays a standard Windows message box with a specific text message. The user will be presented with one or more buttons in the message box where one of the buttons must be chosen. See Tech Support Script Function Library to install this function.

Warning MessageBox() should not be used in either a Condition script or a Data Change script. It may be used in other types of scripts such as Application scripts or Pushbutton Action scripts.

Use:

MessageBox( Message, Title, Style);

Message A Message tag or quoted text (example: “This is the message”). This text will be displayed in the body of the message box.
Title A Message tag or quoted text (example: “Title”). This text will be placed in the title bar of the message box.
Style An Integer tag or an integer representing the button(s) and icon that will be displayed when the message box is displayed. See below on how to construct this integer.

Returns:

MessageBox() returns a value of the button that was selected. (See Return Values below for the return value for each button.). Since the message box being displayed will not allow you to move on before answering, the script in which this function is called will pause until you select one of the choices. If any of the parameter values are invalid, MessageBox() will return a -1.

Note If the message box contains a Cancel button, MessageBox() will return a ‘2’ if the Cancel button is selected or if the user presses the <Esc> key. If it does not contain a Cancel button, pressing <Esc> will have no effect.

Return Values:

Button Selected Return Value
[OK] 1
[CANCEL] 2
[ABORT] 3
[RETRY] 4
[IGNORE] 5
[YES] 6
[NO] 7

Details of MessageBox()

Message can be up to 131 characters containing any valid, printable ASCII character. Title can be up to 131 characters containing any valid, printable ASCII character.

Style must be a number that is the sum of BUTTONTYPE and ICONTYPE. The sum of these two numbers will represent the Style parameter. BUTTONTYPE and ICONTYPE are integers, each of which have a specific meaning.

BUTTONTYPE must be one of the following values:

ButtonType Buttons Displayed
0 [OK]
1 [OK] [CANCEL]
2 [ABORT] [RETRY] [IGNORE]
3 [YES] [NO] [CANCEL]
4 [YES] [NO]
5 [RETRY] [CANCEL]

ICONTYPE must be one of the following values:

IconType Icon Displayed
10 utsts4b.bmp
20 utsts4c.bmp
30 utsts4d.bmp
40 utsts4e.bmp

If you want to have a message box that has YES and NO buttons and the Exclamation point icon displayed, you would calculate the Style parameter as:

BUTTONTYPE (4) + ICONTYPE (30) = Style (34)

Special Note

The first parameter to MessageBox() is the message to be placed in the message box. More than one line can be displayed in the message box by separating the message lines with the StringChar (13) character. Example:

MessageBox (“Level low…” + StringChar (13) + “Stop PUMP1 NOW!”, “Warning”, 0, 1);

Example of Using MessageBox()

The following is an example script that uses MessageBox():

{ This is an example script to demonstrate the use of the MessageBox() function }
{ Call message box to ask the operator if the cleaning cycle should start, or not }
{ If the operator chooses the YES button, the value of myreturn will be 6 }
{ If the operator chooses the NO button, the value of myreturn will be 7 }
myreturn = MessageBox ( “Start Cleaning Cycle?”, “TANK 5 Done Draining”, 24);

The message box displayed will look like this:

You must either select the YES or NO button to remove the message box. You will not be able to select any window behind or beneath the message box until a button has been selected.

2 thoughts on “Intouch Script Function Sample of MessageBox

  1. Unknown Unknown Unknown Unknown

    Is it possible to show the messagebox at a specific location (similar to using the ShowAtTopLeft script)? We have a multi monitor setup. The messagebox always appears in the middle of the set resolution. Since our resolution is set up for three screens, that means it always pops up in the middle of the middle screen, even if the button that calls the message box is on screen 1 or screen 3. This is frustrating for operations.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × 6 =