DISPLAY and formatting

DISPLAY

DISPLAY writes one line to the standard output. Several items in one DISPLAY are concatenated with a single space between them, and a trailing period ends the sentence:

DISPLAY "Employee: " WS-NAME " Rate: " WS-RATE.

EDITED pictures

Edited pictures format numbers for people: Z prints a blank instead of a leading zero, * fills with asterisks for currency, . places the decimal point, and CR shows a negative credit:

01 WS-SALARY-OUT PIC $$$,$$$,$$9.99. MOVE WS-SALARY TO WS-SALARY-OUT. DISPLAY "Salary: " WS-SALARY-OUT.

Line control

For report files, LINE-COUNTER and LINAGE-COUNTER track the page, and WRITE with AFTER ADVANCING controls spacing. Keep DISPLAY for debugging and the Report Writer for finished output.

The code on this page was run with GnuCOBOL 3.2.0 on Alpine Linux 3.24.3 (x86_64) in a Docker container.

Article author: Arthur Isaev

Banner image