xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Alert()

Displays a text-mode dialog box with a message.

Syntax

Alert( <xMessage>, [<aOptions>], [<cColor>], [<nDelay>] ) --> nChoice

Arguments

<xMessage>
This is the message to display in the dialog box. It can be of any data type but is usually a character string or an array filled with strings. If <xMessage> is a character string, the semicolon is treated as a new line character. When it is an array, each element is displayed in a new line of the dialog box.
<aOptions>
<aOptions> is an array filled with character strings. Each element is displayed as prompt for the user to make a selection. If no parameter is passed, <aOptions> defaults to { "Ok" }.
<cColor>
This is a color string holding two color values. The Normal color is used to display the dialog box along with <xMessage>. The options to select from are displayed in the Enhanced color. The default is "W+/R,W+/B".
<nDelay>
Optionally, a numeric value can be specified, indicating the number of seconds to wait for a key press before the dialog box closes automatically. It defaults to zero, which means that the dialog box does not close automatically.

Return

The function returns a numeric value indicating the ordinal position within <aOption> of the prompt selected by the user. When the ESC key is pressed, the user aborted the selection and the return value is 0.

If <nDelay> is specified and this number of seconds has elapsed without a key press, the return value is 1.

Description

Alert() displays a simple text-mode dialog box and lets the user select an option. The user can move a highlight bar using arrow keys or the TAB key. To select an option, the user can press ENTER, SPACE or the first letter of an option.

Info

See also:@...PROMPT, AChoice(), DispBox(), DispOut(), MENU TO
Category: UI functions
Source:rtl\alert.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays a message to terminate or resume the program.
// After 5 seconds without user response, the program quits automatically.

   PROCEDURE Main()
      LOCAL cMessage, aOptions, nChoice

      cMessage := "Quit program?;(auto-quit in 5 seconds)"
      aOptions := { "Yes", "No" }

      nChoice := Alert( cMessage, aOptions, , 5)

      DO CASE
      CASE nChoice == 0
         ? "Program not interrupted ..."
      CASE nChoice == 1
         QUIT
      CASE nChoice == 2
         ? "Program resumed ..."
      ENDCASE

    RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe