Displays messages in the message area at the bottom of the window or in an alert box (or in an output stream—see the Notes section). By default, an area at the bottom line of the window is reserved for ABL system messages. An area above that is reserved for messages you display with the MESSAGE statement.
MESSAGE [ COLOR color-phrase ] { expression | SKIP [ ( n ) ] } ... [ VIEW-AS ALERT-BOX [alert-type] [ BUTTONS button-set ] [ TITLE title-string ] ] [ { SET | UPDATE } field { AS datatype | LIKE field } [ FORMAT string ] [ AUTO-RETURN ] ] [ IN WINDOW window ] |
Displays a message using the color you specify with the COLOR phrase.
NORMAL | INPUT | MESSAGES | protermcap-attribute | dos-hex-attribute | { [ BLINK- ] [ BRIGHT- ] [ fgnd-color ] [ bgnd-color ] } | { [ BLINK- ] [ RVV- ] [ UNDERLINE- ] [ BRIGHT- ] [ fgnd-color ] } | VALUE ( expression ) |
For more information on color-phrase, see the COLOR phrase reference entry.
You can only use this option with the VIEW-AS ALERT-BOX option.
The type of alert box affects the visual representation of the box.
Specifies what sets of buttons are available within the alert box. The possible button sets are as follows:
The name of each button set indicates the buttons in that set. For example, YES-NO contains two buttons labeled YES and NO; YES-NO-CANCEL contains three buttons labeled YES, NO, and CANCEL; OK contains a single button labeled OK. If you do not specify a button set, the default is OK.
For more information on display formats, see OpenEdge Getting Started: ABL Essentials.
If you do not use the FORMAT option, ABL uses the defaults shown in the following table.
Type of expression | Default format |
---|---|
Field | Format from schema |
Variable | Format from variable definition |
Constant character | Length of character string |
Other | Default format for the data type of the expression |
The following table shows the default formats for the Other expression.
Data type | Default display format |
---|---|
CHARACTER | x(8) |
CLASS1 | N/A |
DATE | 99/99/99 |
DATETIME | 99/99/9999 HH:MM:SS.SSS |
DATETIME-TZ | 99/99/9999 HH:MM:SS.SSS+HH:MM |
DECIMAL | ->>,>>9.99 |
HANDLE2 | >>>>>>9 |
INT64 | ->,>>>,>>9 |
INTEGER | ->,>>>,>>9 |
LOGICAL | yes/no |
MEMPTR3 | See footnote 3. |
RAW3 | See footnote 3. |
RECID | >>>>>>9 |
ROWID3 | See footnote 3. |
In this procedure, if you enter the number of a Customer that does not exist, the procedure displays a message telling you the Customer does not exist. If the Customer does exist, the procedure displays the Name and SalesRep of the Customer.
r-msg.p
REPEAT: PROMPT-FOR Customer.CustNum. FIND Customer USING Customer.CustNum NO-ERROR. IF NOT AVAILABLE Customer THEN DO: MESSAGE "Customer with CustNum " INPUT Customer.CustNum " does not exist. Please try another". UNDO, RETRY. END. ELSE DISPLAY Customer.Name Customer.SalesRep. END. |
The following example uses two alert boxes:
r-altbox.p
DEFINE VARIABLE cust-list AS CHARACTER NO-UNDO VIEW-AS SELECTION-LIST SINGLE SIZE 50 BY 10 LABEL "Customers". DEFINE VARIABLE ok-status AS LOGICAL NO-UNDO FORM cust-list WITH FRAME sel-frame. ON DEFAULT-ACTION OF cust-list DO: MESSAGE "You have chosen to delete" cust-list:SCREEN-VALUE + "." SKIP(1) "Do you really want to delete this customer?" VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO-CANCEL TITLE "" UPDATE lChoice AS LOGICAL. CASE lChoice: WHEN TRUE THEN /* Yes */ DO: FIND Customer WHERE Customer.Name = cust-list:SCREEN-VALUE EXCLUSIVE-LOCK. DELETE Customer. END. WHEN FALSE THEN /* No */ DO: MESSAGE "Deletion canceled." VIEW-AS ALERT-BOX INFORMATION BUTTONS OK. RETURN NO-APPLY. END. OTHERWISE /* Cancel */ STOP. END CASE. END. FOR EACH Customer NO-LOCK BY Customer.Name: ok-status = cust-list:ADD-LAST(Customer.Name). END. ENABLE cust-list WITH FRAME sel-frame. WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW. |
In r-altbox.p, each time you select an item from the selection list, the procedure displays an alert box to ask if you want to delete the customer. If you choose the No button, then another alert box informs you that the record was not deleted.
If you want to send output to a destination other than the terminal, and you do not want messages to appear on the terminal (and if you are not using the terminal as an input source), use one of the statements in the following table.
Operating system | Input from |
---|---|
UNIX | INPUT FROM /dev/null |
Windows | INPUT FROM NUL |
Be sure to use the INPUT CLOSE statement to close the input source.
When you use the MESSAGE SET or MESSAGE UPDATE statement to update a field, the AVM does not process any validation criteria defined for that field in the database. For example, if the validation criteria for the customer.name field is as follows:
Use this statement:
The AVM lets you enter any data, including data that does not start with the letter a, into the name field.
Use the MESSAGE statement to display a message, but use the SET statement or UPDATE statement to let the user change the data in a frame rather than in the message area.
If you are displaying a message to the message line and the combination of the text and field you name in a MESSAGE UPDATE statement exceeds the length of the message line, the AVM truncates the text to fit on the message line. For example:
DEFINE VARIABLE myvar AS CHARACTER NO-UNDO FORMAT "x(60)". MESSAGE "abcdefghijklmnopqrstuvwxyz" UPDATE myvar. |
Here, the combination of the message text and the myvar variable exceeds 80 characters, so the AVM truncates the message text.
Using the MESSAGE statement to display decimal values results in truncating the nonsignificant zeros to the right of the decimal point. For example:
The previous procedure displays the following message:
Use functions such as STRING and DECIMAL to control the format of a display.