MessageBox
Displays a GUI message box with text, icon and buttons.
Syntax
-
MessageBox(s[, i][, b[, db[, cb]]])
-
s
is string -
i
is a string -
b
is a list of strings -
db
is a string -
cb
is a string
-
Description
The MessageBox
function displays a message box with text, optionally with an icon, and with a custom set of buttons.
-
s
is the text of the message box. -
i
is the type of icon. If present, it must be one of"information"
,"warning"
, and"error"
. The icon may be accompanied by a distinctive sound. Both the visual icon bitmap and the sound are provided by the operating system and may be affected by system settings. If omitted, no icon is displayed. -
b
is a list of the dialog’s buttons. Each element is a string which is used both as the caption of the button and as its identifier. An caption may contain an ampersand character indicating that the next character is the button’s accelerator. To include an actual ampersand character, write&&
. If omitted,b
defaults to'("OK")
. -
db
specifies the default button. This must be one of the elements ofb
(*). If omitted, the first button becomes the default button. -
cb
specifies the cancel button. This must be one of the elements ofb
(*). If omitted, there is no cancel button. The cancel button is the one that responds to the Escape key and the one that is implicitly chosen if the user closes the dialog box without clicking one of the buttons, typically by clicking the Close title bar button, choosing the Close system menu item, or pressing Alt+F4. Ifcb
is not specified, there will be no Close system menu item or Close title bar button, and the dialog can be closed neither by Escape or by Alt+F4.
(*) Accelerator characters in b
are ignored.
The function returns the caption of the chosen button, without any accelerator ampersand. Please note that this function doesn’t return without user intervention.
Examples
MessageBox("The value of π is " + π + ".", "information")
if(MessageBox("Do you want to exit?", '("&Yes", "&No"), "Yes", "No") = "Yes", exit())
MessageBox("There might be a nargle nearby.", "warning", '("Okay, I’ll be careful."))