Function
Format 1 | is used to output small quantities of data. |
Format 2 | is used to access a POSIX command line. |
Format 3 | are used to access a BS2000 or POSIX environment variable. |
Format 1
DISPLAY { literal-1 | identifier-1 }... [ UPON mnemonic-name ] [WITH NO ADVANCING]
Syntax rules
If literal-1 is numeric, it must be an unsigned integer.
identifier-1 must not be of the class national, pointer or object.
mnemonic-name must be specified in the SPECIAL-NAMES paragraph and be associated with one of the following implementor-names:
CONSOLE, PRINTER, PRINTER01 - PRINTER99, SYSOPT, TERMINAL, job-variable-name (BS2000 job variable).The mnemonic-name for SYSOPT, TERMINAL, CONSOLE, PRINTER and PRINTER01 - PRINTER99 specifies the system file into which the data is to be written.
SYSOPT specifies the system file with the same name.
TERMINAL specifies the system file SYSOUT.
CONSOLE specifies the system operator console.
PRINTER specifies the system file SYSLST, and PRINTER01 - PRINTER99 refer to the system files SYSLST01 - SYSLST99.
If the UPON phrase is omitted, the data is written by default to the logical output file SYSLST. Data can also be written to the logical output file SYSOUT by means of an appropriate compiler directive (see the "COBOL2000 User Guide" [1]).
identifier-1 must not be defined with the ANY LENGTH clause.
General rules
literal-1 or identifier-1 serves to specify the operands in the order they are to be output. If necessary, the contents of the data item specified by "identifier" are converted to external formats according to the following rules:
Internal decimal and binary items are converted to external decimal data items.
Internal floating-point data items are converted to external floating-point data items.
No other data items require conversion.
If one of the operands is the figurative constant ALL literal, the literal is output once.
If one of the operands is a figurative constant (except ALL literal), it is output with length 1.
A maximum logical record size is assumed for each device. These sizes are listed in table 27.
Device Maximum record size CONSOLE 180 characters PRINTER
PRINTER01_PRINTER99132 characters + 1 control byte SYSOPT 80 characters: 72 data bytes; bytes 73-80 contain the first 8 bytes of the PROGRAM-ID name. TERMINAL 8192 characters Table 27: Maximum logical record size for the DISPLAY statement
When a DISPLAY statement contains more than one operand, the contents of the specified operands and literals are displayed adjacent to each other, from left to right.
Zero-length items are not displayed. If all operands are zero-length items, the DISPLAY statement has no effect.The compiler treats the NO ADVANCING phrase as a comment.
For output to printer, the following entries cause a line feed: DISPLAY, WRITE and WRITE AFTER ADVANCING. A WRITE statement without ADVANCING phrase and a WRITE statement with BEFORE ADVANCING phrase causes the printer to space after printing. Therefore, mixed use of DISPLAY and WRITE statements on the same device within the same program may cause two or more lines to overprint. Overprinting is not possible on laser printers.
The maximum record length for job variables is 256 characters.
If the total number of characters in the operands exceeds the maximum record length, the record will be truncated to the maximum length.When a job variable is used as a monitoring job variable (MONJV), the system protects the first 128 bytes (system portion) of this job variable against write access. Therefore, only that portion of a record that begins at position 129 will be written from position 129 of the monitoring job variable. In all other respects, general rule 4 applies for monitoring job variables.
For further information see the "COBOL2000 User Guide" [1].
Example 8-31
SPECIAL-NAMES. TERMINAL IS SPECIAL-OUTPUT. ... PROCEDURE DIVISION. ... DISPLAY OUTPUT-MESSAGE UPON SPECIAL-OUTPUT.
Here, the mnemonic-name SPECIAL-OUTPUT is associated with the implementor-name TERMINAL in the SPECIAL-NAMES paragraph. The DISPLAY statement writes the current contents of OUTPUT-MESSAGE on SYSOUT.
Example 8-32
DISPLAY "Hello world".
Since the UPON phrase is omitted, the literal "Hello world" is written to the logical output device SYSLST. If the compiler directive COMOPT REDIRECT-ACCEPT-DISPLAY=YES (in SDF: ACCEPT-DISPLAY-ASSGN=*TERMINAL) is specified, the literal is written to the output file SYSOUT (see the "COBOL2000 User Guide" [1]).
The following three formats of the DISPLAY statement are extensions from the X/Open Portability Guide. They allow access to environment variables and command lines. Access to command lines is meaningful only if the object program is executing in the POSIX subsystem available as of BS2000/OSD V2.0. Execution of the COBOL2000 compiler and of any programs generated by it under POSIX is described in the "COBOL2000 User Guide" [1].
Format 2
This format sets the number of the argument in the command line which is subsequently accessed via an ACCEPT statement.
DISPLAY { identifier-3 | integer-1 } UPON mnemonic-name-3 [END-DISPLAY]
Syntax rules
identifier-3 must refer to an elementary item that is described as an unsigned integer.
integer-1 must be unsigned.
mnemonic-name-3 must be linked in the SPECIAL-NAMES paragraph with the implementor-name ARGUMENT-NUMBER.
Format 3
This format sets the name of the environment variable which is subsequently accessed by an ACCEPT or DISPLAY statement.
DISPLAY { identifier-4 | literal-1 } UPON mnemonic-name-5 [END-DISPLAY]
Syntax rules
identifier-4 must refer to an alphanumeric elementary item which is not defined with the ANY LENGTH clause.
literal-1 must be an alphanumeric literal.
mnemonic-name-5 must be linked in the SPECIAL-NAMES paragraph with the implementor-name ENVIRONMENT-NAME.
Format 4
This format writes to the environment variable specified previously in a format-3 DISPLAY statement.
DISPLAY {identifier-2 | literal-2 } UPON mnemonic-name-6
[ON EXCEPTION imperative-statement-1]
[NOT ON EXCEPTION imperative-statement-2]
[END-DISPLAY]
Syntax rules
identifier-2 must refer to an alphanumeric elementary item which is not defined with the ANY LENGTH clause.
literal-2 must be an alphanumeric literal.
mnemonic-name-6 must be linked in the SPECIAL-NAMES paragraph with the implementor-name ENVIRONMENT-VALUE.
NOT ON EXCEPTION can only be specified if ON EXCEPTION is also specified.
A detailed example of accessing command lines and environment variables can be found in chapter 12 of the COBOL User Guide [1].