The DISPLAY statement is an ABL statement that can be used for displaying output. This statement can be used in conjunction with the built-in user interface (UI). Most modern applications do not use the built-in UI for showing output, but the built-in UI can be useful when prototyping or debugging your code. The built-in UI is helpful when learning ABL, because you can try ABL code and quickly display the output without having to learn another UI.

When using the DISPLAY statement to display the value of a variable, you can either use the ABL default display format for the data type of the variable, or you can specify a custom display format. You specify a custom format by using the FORMAT phrase in the DEFINE VARIABLE statement.

The simplified syntax for the DEFINE VARIABLE statement, with the FORMAT phrase, is shown:
DEFINE VARIABLE variable-name AS data-type
     [ FORMAT "format-phrase" ] [ NO-UNDO ].

In the following example code, the DEFINE VARIABLE statements for the myStrCustom and myDecCustom variables override the default formatting. myStrCustom is defined to display twenty characters. myDecCustom is defined to display four decimal places. For comparison purposes, two additional variables are defined, myStrDefault and myDecDefault, which do not alter the default formatting.

DEFINE VARIABLE myStrDefault AS CHARACTER NO-UNDO.
DEFINE VARIABLE myStrCustom AS CHARACTER FORMAT "x(20)" NO-UNDO.
DEFINE VARIABLE myDecDefault as DECIMAL NO-UNDO.
DEFINE VARIABLE myDecCustom as DECIMAL FORMAT "->>,>>9.9999" NO-UNDO.

myStrDefault = 'abcdefghijklmnopqrstuvwxyz'.
myStrCustom = 'abcdefghijklmnopqrstuvwxyz'.
myDecDefault = 123.456789.
myDecCustom = 123.456789.

DISPLAY myStrDefault myStrCustom myDecDefault myDecCustom.

Running the code produces the following output:

myStrDefault myStrCustom          myDecDefault  myDecCustom
------------ -------------------- ------------ ------------
abcdefgh     abcdefghijklmnopqrst       123.46     123.4568

For more information on the default display formats, see DEFINE VARIABLE statement.

Note: Neither default nor custom display formats apply to the MESSAGE statement.