Back to Contents


Displaying Messages

Summary:


DISPLAY

Purpose:

The DISPLAY instruction displays text in line mode to the standard output channel.

Syntax:

DISPLAY expression [,...]

Notes:

  1. expression is any expression supported by the language.

Usage:

You can use this instruction to display information to the standard output channel.

The values contained in variables are formatted based on the data type and environment settings.

Example:

01 MAIN
02   DISPLAY "Today's date is: ", TODAY
03 END MAIN

ERROR

Purpose:

The ERROR instruction displays an error message to the user.

Syntax:

ERROR expression [,...] [ ATTRIBUTE ( display-attribute [,...] ) ]

Notes:

  1. expression is any expression supported by the language.
  2. display-attribute is an attribute to display the error text. See below.

Usage:

The ERROR instruction displays an error message to the user.

In TUI mode, the error text is displayed in the Error Line of the current window. In GUI mode, the text is displayed in a specific area, depending on the front end configuration.

Possible attributes that can be used as display-attribute:

Attribute Description
STYLE = string The name of a Presentation Style.
BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, WHITE, YELLOW The color of the displayed text.
BOLD, DIM, INVISIBLE, NORMAL The font attribute of the displayed text.
REVERSE, BLINK, UNDERLINE The video attribute of the displayed text.

When you specify the STYLE attribute, you can reference a style defined in the Presentation Styles file. This allows you to display errors or messages with more sophisticated visual effects as the regular TTY attributes. Advanced automatic rendering can be obtained with Message specific style attributes. Note that if you want to apply automatically a style to all program warnings displayed with the ERROR instruction, you can use the :error pseudo selector in the style definition.

Example:

01 MAIN
02    WHENEVER ERROR CONTINUE
03    DATABASE stock
04    WHENEVER ERROR STOP
05    IF sqlca.sqlcode THEN
06       ERROR "Connection failed (" || sqlca.sqlcode || ")"
07    END IF
08 END MAIN

MESSAGE

Purpose:

The MESSAGE instruction displays a message to the user.

Syntax:

MESSAGE message [,...] [ ATTRIBUTE ( display-attribute [,...] ) ]

Notes:

  1. expression is any expression supported by the language.
  2. display-attribute is an attribute to display the error text. See below.

Usage:

The MESSAGE instruction displays a message to the user.

In TUI mode, the text is displayed in the Comment Line of the current window. In GUI mode, the text is displayed in a specific area, depending on the front end configuration.

Possible attributes that can be used as display-attribute:

Attribute Description
STYLE = string The name of a Presentation Style.
BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, WHITE, YELLOW The color of the displayed text.
BOLD, DIM, INVISIBLE, NORMAL The font attribute of the displayed text.
REVERSE, BLINK, UNDERLINE The video attribute of the displayed text.

When you specify the STYLE attribute, you can reference a style defined in the Presentation Styles file. This allows you to display errors or messages with more sophisticated visual effects as the regular TTY attributes. Advanced automatic rendering can be obtained with Message specific style attributes. Note that if you want to apply automatically a style to all program messages displayed with the MESSAGE instruction, you can use the :message pseudo selector in the style definition.

Example:

01 MAIN
02    WHENEVER ERROR CONTINUE
03    DATABASE stock
04    WHENEVER ERROR STOP
05    IF sqlca.sqlcode THEN
06       ERROR "Connection failed (" || sqlca.sqlcode || ")"
07    ELSE
08       MESSAGE "Connected to database." ATTRIBUTE (STYLE="info3")
09    END IF
10 END MAIN