Functions and Directives

Function Alert() Foundation

Displays a modal dialog box.

Alert( <cMessage>, [<aOptions>], [<cColor>] ) --> nChoice
<cMessage> is a character string which is displayed centered in the dialog box. The character string can be split using a semicolon to indicate where output is to continue on a new line.
<aOptions> is an array with a maximum of four elements. Each element contains a character string which is displayed as a menu option below the text <cMessage>. If <aOptions> is missing, the default is to output the single menu option " Ok ".
The optional argument <cColor> specifies colors for the screen display of the dialog box and menu items. If <cColor> is missing, display occurs using the system colors defined with SetColor().

The return value of Alert() is a numeric value indicating the position of the selected menu option within the array passed. If the Esc key is pressed, Alert() returns the value zero.


The dialog function Alert() displays a modal dialog box containing text and optional menu items. Alert() saves and restores the screen by itself. The function is used in error handling or when a choice among a maximum of four possibilities must be made by the user. A menu is displayed with the options specified in <aOptions> and the user can select an option using the highlight. The highlight is moved with the arrow keys, the selection occurs by pressing the return key or the space bar. If the function SetMouse(.T.) is called before the call to Alert(), selection can also be made by clicking the left mouse button. When the Esc key is pressed, Alert() terminates and returns the value zero.

If <cColor> is passed, the dialog box and text are displayed in the default color (first color value) and the current menu item in the highlighted color (second color value). The menu items not selected are displayed in the fifth color value.

The function Alert() works independently of other functions in the Xbase++ runtime library and guarantees output on the screen will occur. If screen output is required within an error handling routine for critical errors, it should be done using Alert().

// The example shows a typical situation for using Alert(): 
// to check whether an existing file should be overwritten. 

   LOCAL nOption, cText, cFile := "TEST.TXT" 

   cText := MemoEdit( MemoRead(cFile) ) 

   IF File(cFile) 
      nOption := Alert( "File already exists"   , ; 
                        {"Overwrite","Cancel"} ) 
      nOption := 1 

   IF nOption == 1 
      MemoWrit( cFile, cText ) 



If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.