MESSAGE statement
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.
Syntax
COLORcolor-phrase
Displays a message using the color you specify with the COLOR phrase.
For more information oncolor-phrase
, see the COLOR phrase reference entry.Note: The COLOR phrase does not have any effect in a Windows environment.expression
SKIP [ (n
) ]VIEW-AS ALERT-BOX [alert-type
]BUTTONSbutton-set
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.TITLEtitle-string
SETfield
UPDATEfield
Displays theexpression
you specified and updates the field or variable you name. (It displays the current value of the field or variable, prompts for input, and assigns the value entered in the field or variable.) You cannot test the field with the ENTERED function or the NOT ENTERED function. For an alert box,field
must be a LOGICAL variable. It sets the default button and returns the user’s choice. If the alert box has two buttons, they represent the values TRUE and FALSE, respectively. If the alert box has three buttons, they represent the values TRUE, FALSE, and the Unknown value (?
), respectively.ASdatatype
LIKEfield
FORMATstring
The format that you want to use to display thefield
used in the SET or UPDATE option.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 Table 44.
Table 45 shows the default formats for the Other expression.
Table 45: Default data type display formats 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 the footnote at the end of the table. RAW3 See the footnote at the end of the table. RECID >>>>>>9 ROWID3 See the footnote at the end of the table.
1For a class instance, ABL automatically invokes the ToString( ) method (provided by the Progress.Lang.Object class) on the object reference. Instead, you can also first explicitly convert the object reference to a displayable type using the INT64 function, the INTEGER function, or the STRING function.
2To display a HANDLE, you must first convert it using either the INT64 or INTEGER function and display the result.
3You cannot display a MEMPTR, RAW, or ROWID value directly. However, you can convert it to a character string representation using the STRING function and display the result. A ROWID value converts to a hexadecimal string, “0xhexdigits
,” wherehexdigits
is any number of characters “0" through “9" and “A” through “F”. A MEMPTR or RAW value converts to decimal integer string.AUTO-RETURNIN WINDOWwindow
ExamplesIn 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
andSalesRep
of the Customer.
The following example uses two alert boxes:
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.Notes
- The MESSAGE statement always sends messages to the current output destination. If the INPUT source is the terminal, the AVM displays messages in the window and also sends them to the current output destination. Compiler error messages also follow this convention.
- If you don’t want messages sent to the current output destination, redirect the output to a named stream. The AVM never writes messages to a named stream.
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 Table 46.
Table 46: Suppressing messages to the terminal Operating system Input from UNIX INPUT FROM /dev/null Windows INPUT FROM NULBe sure to use the INPUT CLOSE statement to close the input source.- The AVM automatically clears messages after any user interaction, such as a SET, UPDATE, or PAUSE statement, but not after a READKEY statement.
- In Microsoft Windows, the message text in VIEW-AS ALERT-BOX is limited to 511 bytes. If the text is longer than 511 bytes, it is truncated.
- 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:
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.- If the APPL-ALERT-BOXES attribute of the SESSION system handle is TRUE, then all your messages are displayed in alert boxes. You can also direct all system messages to alert boxes by setting the SYSTEM-ALERT-BOXES attribute of the SESSION system handle to true. You can remove the message area for a window by setting its MESSAGE-AREA attribute to FALSE before it is realized.
- If you use the SET or UPDATE options in a graphical environment, the AVM automatically displays the message as an alert box.
- By default, all text in an alert box is displayed on a single line. If you want to break lines within the text, you must explicitly insert SKIP options into the message.
- If you use the OUTPUT TO statement to divert ABL error and warning messages to an output stream, ABL also diverts messages from the MESSAGE statement the same way. For more information, see the OUTPUT TO statement reference entry.
- The MESSAGE statement does not raise ERROR if the AVM fails to resolve an output expression. Instead, the empty string will be displayed at the specified output location. However, if the block containing the MESSAGE statement contains a CATCH block, then the MESSAGE statement will raise ERROR and you can handle that error with a compatible CATCH block.
- You can use the MESSAGE statement with an object reference for a class instance. In this case, the MESSAGE statement implicitly calls the ToString( ) method of the class to convert the specified object reference to a character value before it displays the result.
- For SpeedScript, the only valid options are:
expression
and SKIP.See alsoCOLOR phrase, DECIMAL function, Format phrase, INTEGER function, MESSAGE-LINES function, STRING function
OpenEdge Release 10.2B
|