Progress
Language Tutorial
for Windows


Using Alert Boxes

An alert box is a dialog box for the message area of a window widget. An alert box is like a dialog box in that an alert box blocks the rest of the interface until the user acknowledges the alert box. When a message is important enough to interrupt the user, then the alert box is the right interface component to use. Here’s the alert box syntax, which is included in the MESSAGE statement.

SYNTAX
[  VIEW-AS ALERT-BOX alert-type BUTTONS button-set
   [ TITLE title-string ]
] 

Table 12–3 describes the alert box options.

Table 12–3: Alert Box Options 
Component
Description
alert-type
Different environments define different types of alert boxes for use in certain circumstances. This ensures that all applications running in the environment use the same graphical cues for similar situations. This kind of uniformity helps the user recognize the seriousness of the message. The three most common types are:
  • MESSAGE — Specify this keyword when you want to communicate important information about the normal operations of an application. For example, “The new records have been added to the database.”
  • QUESTION — Specify this keyword when you need to have the user answer a yes/no question before the application can proceed or you want the user to confirm a decision. For example, “Do you really want to delete the record?”
  • INFORMATION — Specify this keyword when you want to give the user information. Use this type to provide the user with information they specifically request. For example, you might have a button named Version. When the user chooses the button, an alert box comes up displaying the version number of your software.
button-set
While the alert-type syntax lets you specify the type of message to send, the BUTTON-SET syntax lets you choose the method for user response to the alert box. The most common button sets are:
  • OK — Use the OK button set with both the MESSAGE and INFORMATION alert box types. The user chooses the OK button to dismiss the alert box.
  • YES-NO — Use this button set with the QUESTION alert box type. The alert box will return the logical value YES or NO depending on the choice of the user to a LOGICAL field specified in the MESSAGE statement. See below for a description of this technique.
TITLE
Like a frame or dialog box, an alert box can have a title. Good style dictates that you always include a descriptive title.

Returning a Logical Value from an Alert Box

Earlier, you ran a code example that deleted records. In that example, you saw an alert box used to make the user confirm a deletion request. Figure 12–4 shows that alert box.

Figure 12–4: QUESTION Alert Box

This is the QUESTION alert box type and it uses the YES-NO button set.

The code fragment below shows the relevant part of procedure lt-08-06.p:

              .
              .
              .
/*1*/  DEFINE VARIABLE Answer AS LOGICAL.
              .
              .
              . 
      ON CHOOSE OF btn-Delete
      DO:
/*2*/      MESSAGE "Do you really want to delete" Customer.Name "?"
              VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO
/*3*/      UPDATE Answer.
/*4*/        IF Answer THEN DO:
             DELETE Customer.
             GET NEXT Cust-Query.
            IF NOT AVAILABLE(Customer) THEN GET FIRST Cust-Query.
            DISPLAY Customer.Cust-Num Customer.Name WITH FRAME Frame1.
          END. /* IF Answer */
      END. /* ON CHOOSE OF btn-Delete */
              .
              .
              . 

These notes help explain the code:

  1. You need to define a variable before you use the alert box to store the user’s response.
  2. The special VIEW-AS syntax on a MESSAGE statement re-routes a message from the status area to an alert box.
  3. This UPDATE is an option of the MESSAGE statement (note that there is no period on the line before). Use this option to specify the variable that will hold the user’s response.
  4. If the user answers YES, then the DELETE statement executes.

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095