messagebox

The messagebox function enables you to display a message box for which you have designated the format and content. You can specify the number and type of buttons on the message box, the message icon (for example, hand, question mark, exclamation point, or asterisk), and the message displayed. You can also issue a return value based on the chosen action.

Common use

The messagebox function is used to help debug a map. Messages placed throughout a map can help determine where a hung map is hanging. Multiple messages can be combined into one string to avoid confusion about the results. Instead of receiving three messageboxes with the values of three fields, you can combine them all into one messagebox, with labels. For example:

String[100] msg;

msg = “field1: “ + #field1 + “ field2: “ + #field2 + “ field3: “ + #field3;
messagebox(msg,0);

This will output one string with the values for the three fields in line:

field1: value field2: value field3: value
Note: Only String values can be displayed in a message box.

Syntax

messagebox("message",defined_number);

where:

  • message = message string
  • defined_number = defined number of the desired buttons plus the defined number of the desired icon (if used)

The defined numbers for the button and icon types are as follows:

  • 0 = OK button only
  • 1 = OK and Cancel buttons
  • 4 = Yes and No buttons
  • 16 = Icon Hand
  • 32 = Icon Question Mark
  • 48 = Icon Exclamation Point
  • 64 = Icon Asterisk

The message box return values are as follows:

  • 1 = OK selected
  • 2 = Cancel selected
  • 6 = Yes selected
  • 7 No selected

Example

if messagebox("Do you really want to delete this object?",36) = 6
begin
.
.
.
end
//Displays a message box with the given string as the message, Yes
//and No buttons (4) and a question mark icon (32). The number and
//type of buttons (4) plus the icon (32) equals the defined_number(36). 
//If the user clicks the Yes button (return value "6"), the
//statements in the begin/end loop are executed.

Defined_
numbers

Table 1. defined_numbers for the button and icon types
Defined_Number Button or Icon Types
0 OK button only
1 OK and Cancel buttons
4 Yes and No buttons
16 Icon Hand
32 Icon Question Mark
48 Icon Exclamation Point
64 Icon Asterisk

Message box return values

Table 2. Message box return values
Return Value Action Selected
1 OK selected
2 Cancel selected
6 Yes selected
7 No selected