Progress
Language Reference


MESSAGE Statement

Interfaces
OS
SpeedScript
All
All
Yes

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 Progress system messages. An area above that is reserved for messages you display with the MESSAGE statement.

SYNTAX

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 ] 

COLOR color-phrase

Displays a message using the color you specify with the COLOR phrase.

SYNTAX
   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.

NOTE: The COLOR Phrase does not have any effect in a Windows environment.

expression

An expression (a constant, field name, variable name, or expression) whose value you want to display in the message area. If expression is not character, it is converted to character before it is displayed. If you do not use this option, you must use either the SET or UPDATE option.

SKIP [ ( n ) ]

Indicates a number (n) of blank lines to insert into the message. The value of n can be 0. If you do not specify n, or if n is 0, a new line is started unless the current position is already the start of a new line.

You can only use this option with the VIEW-AS ALERT-BOX option.

VIEW-AS ALERT-BOX [ alert-type ]

Specifies that the message is displayed in an alert box rather than in the window message area. The value of alert-type determines the type of alert box. The possible values are:

BUTTONS button-set

Specifies what sets of buttons are available within the alert box. The possible button sets are as follows:

TITLE title-string

Specifies a value to display in the title bar of the alert box.

SET field

Displays the expression you specified and SETs the field or variable you name. (It prompts the user for input and assigns the value entered to the field or variable.) You cannot test the field with the ENTERED function or the NOT ENTERED function.

UPDATE field

Displays the expression 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 unknown (?), respectively.

AS datatype

Defines field as a variable of type datatype. You must use this option or the LIKE option if field has not been previously defined.

LIKE field

Defines the field specified in SET or UPDATE as a database field or a previously defined variable.

FORMAT string

The format that you want to use to display the field used in the SET or UPDATE option. For more information on display formats, see the Progress Programming Handbook . If you do not use the FORMAT option, Progress uses the defaults shown in Table 31.

Table 31: Default Display Formats 
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

Table 32 shows the default formats for the Other expression.

Table 32: Default Data Type Display Formats 
Data Type
Default Display Format
CHARACTER
x(8)
DATE
99/99/99
DECIMAL
->>,>>9.99
HANDLE
>>>>>>9
INTEGER
->,>>>,>>9
LOGICAL
yes/no
MEMPTR1
See the footnote at the bottom of the table.
RAW1
See the footnote at the bottom of the table.
RECID
>>>>>>9
ROWID1
See the footnote at the bottom of the table.
WIDGET-HANDLE
>>>>>>9
  1. You 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,” where hexdigits is any number of characters “0" through “9" and “A” through “F”. A MEMPTR or RAW value converts to decimal integer string.

AUTO-RETURN

Performs a carriage return when the field that is SET or UPDATEd is full.

IN WINDOW window

Specifies the window in which the message is displayed.

EXAMPLES

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 sales-rep of the customer.

r-msg.p
REPEAT:
    PROMPT-FOR customer.cust-num.
    FIND customer USING cust-num NO-ERROR.
    IF NOT AVAILABLE customer
    THEN DO:
        MESSAGE "Customer with cust-num " INPUT cust-num
                " does not exist.  Please try another".
        UNDO, RETRY.
    END.
    ELSE DO:
        DISPLAY name sales-rep.
    END.
END. 

The following example uses two alert boxes.

r-altbox.p
DEFINE VARIABLE cust-list AS CHARACTER VIEW-AS SELECTION-LIST
                           SINGLE SIZE 50 BY 10 LABEL "Customers".
DEFINE VARIABLE ok-status AS LOGICAL.                           

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 choice AS LOGICAL.
      CASE choice:
         WHEN TRUE THEN /* Yes */
          DO:
            FIND customer WHERE 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 BY 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.

NOTES

SEE ALSO

COLOR Phrase, DECIMAL Function, Format Phrase, INTEGER Function, MESSAGE-LINES Function, STRING Function


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