Use the MESSAGE statement
- Last Updated: July 22, 2025
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Next you need to display a warning message if there are no results, which means that no
Customer records match the state value that was entered. ABL has a
MESSAGE statement to display a message to the screen or to a
message area at the bottom of the window if there is one. A MESSAGE
statement can contain one or more character expressions (quoted literals or CHARACTER
variables) that make up the message. If there are multiple expressions in the statement,
ABL simply concatenates them all, with a single space between them. You can also insert
the SKIP keyword anywhere in the message to skip a line, or
SKIP(n) to skip n
lines.
If you want the message to appear in its own alert box, you can include the phrase
VIEW-AS ALERT-BOX in the statement. This is the default if the
message is displayed from a GUI window. If you want to give the message alert box a
special format, you can include one of the QUESTION,
INFORMATION, ERROR, or WARNING
keywords after the VIEW-AS ALERT-BOX phrase. The
MESSAGE statement has other features, including the ability to
display different sets of buttons, beyond just an OK button to
acknowledge the message. It can also capture an answer from the message and store it in
a variable. You can see all the syntax details in MESSAGE
statement in the ABL Reference.
To display a warning message that tells you that there are no matching Customers:
- In the New State trigger, add this code (in
bold):
iMatches = NUM-RESULTS("CustQuery") IF iMatches = 0 THEN DO: MESSAGE "There are no Customers that match the State" cState:SCREEN-VALUE "." SKIP "Restoring the previous State." VIEW-AS ALERT-BOX WARNING. APPLY "CHOOSE" TO BtnFirst. - Continue adding code. Reopen the query using the value of the
State field that you saved off in the
cStatevariable and redisplay the previous valid New State value:/* Reopen the query with the previous state. */ OPEN QUERY CustQuery FOR EACH Customer WHERE Customer.State = cState BY Customer.City. /* Display the previous valid state as well. */ DISPLAY cState WITH FRAME CustQuery. END.This ends the
DOblock that is executed ifNUM-RESULTSis zero. - To display the number of matching Customers if
NUM-RESULTSis not zero, add the following code:ELSE DISPLAY iMatches WITH FRAME CustQuery. - Save the procedure as h-CustOrderWin4.w.
- Run the procedure to see the number of matching records for
any State you enter:
- To see your warning message, enter an invalid State value,
such as QQ: