Alert, AlertBox Functions

Purpose

Draws a message box on the screen.

Syntax

Alert[Box] IconAndFlag, MainText$, DefButton, ButtonText$ [,RetVal]

RetVal = Alert[Box](IconAndFlag, MainText$, DefButton, ButtonText$)

IconAndFlag, DefButton:  iexp
RetVal:  ivar
MainText$, ButtonText$: sexp

Description

An Alert box is a special form of a message box. It is used when a point in a program is reached where the program is to be cancelled, a certain branch is to be taken, or some other user decision is to be made.

The first integer expression, IconAndFlag, determines which symbol will be included in the Alert box together with the message. The following symbols are available:

IconAndFlagMeaning
0mark symbol
1stop mark
2question mark
3exclamation mark
4information mark
5windows flag
6application mark
7information mark
16buttons are placed at the right border
32shadow
64text is right aligned
128text is centered

MainText$ contains the message which is to be displayed in the Alert Box. If the text is too long for one line it can be split in up to 4 lines by using "|".

ButtonText$ contains up to five possible alternatives for user response.

DefButton indicates which of these alternatives the default is. This alternative is then selected by pressing the Return key. The alternatives are numbered from 1 to 5 and are separated from each other by a "|".

RetVal contains the number of the alternative which was actually selected.

To ensure that the Alert box is centred on its owner, use the DlgCenter[Hook] command.

Example

$Library "UpdateRT"

UpdateRuntime      // Patches GfaWin23.Ocx - needed to fix White background bug

Local a$, b$, retval%

OpenW 1

a$ = "Which procedure should|be executed next"

b$ = "Input | Calculate | Print | File output | CANCEL"

retval% = 0

Alert 2 | 16, a$, 1, b$, retval%

Print "Return Value:"; retval%

Do : Sleep : Until Win_1 Is Nothing

Creates an Alert Box with a question mark as symbol and the message: "Which procedure should be executed next". The default alternative is "Input". The alternatives are:

Input, Calculate, Print, File output, and CANCEL.

retval% contains the number of the selected alternative. This returns 1 if the first alternative is selected, 2 for the second, and so on; if the Alert Box is terminated irregularly, 0 is returned.

Remarks

AlertBox is a synonym to Alert and can be used instead.

In addition to the menu bar and pop-up menus, the Alert[Box] is a third possible way of communication between the program and the user. Furthermore, it can prove useful when incorporated inside LG32 libraries as a customised messagebox, where OCX objects and Dialogs can not be used.

Known Issues

See Also

DlgCenter, DlgCenterHook, Menu, Message, MsgBox, Popup, Prompt

{Created by Sjouke Hamstra; Last updated: 06/03/2022 by James Gaite}