COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

cannot be a data item; therefore, if you have a message that must be displayed on several devices,
you need one DISPLAY statement for each device.
Writing to a Terminal or Printer
When a process includes code from an HP COBOL program having a DISPLAY statement without
a mnemonic name attached, the process delivers characters to its OUT file. If no OUT file was
specified in the initiation of the process, the process inherits the OUT file of its parent (the command
interpreter, if the process was initiated with a RUN command). If the name of the specified OUT
file is all spaces, the characters are discarded.
To display characters to device $DDD or printer $PPP that is not the OUT file of the process, use
the qualified form of the DISPLAY statement; for example:
DISPLAY "Hello" UPON MY-NAME-FOR-DOLLAR-DDD.
The compiler accepts this form of the DISPLAY statement only if it has already encountered an entry
in the SPECIAL-NAMES paragraph associating MY-NAME-FOR-DOLLAR-DDD with the device $DDD;
for example:
SPECIAL-NAMES.
FILE "$DDD" IS MY-NAME-FOR-DOLLAR-DDD.
Each time a DISPLAY statement in a process executes, the process opens the terminal or printer,
transmits the characters, and closes the terminal or printer. Some other process could open the
terminal or printer for exclusive use and hold it open, causing the next DISPLAY or ACCEPT statement
that tries to reach it to get a “device in use” error.
Reading From a Terminal or Process
When a process includes code from an HP COBOL program having an ACCEPT statement without
a mnemonic name attached, the process reads characters from its IN file; if no IN file was specified,
the process reads characters from its home terminal.
To read characters from terminal $TTT or process $QQQ that is not the IN file of the process, use
the qualified form of the ACCEPT statement; for example:
ACCEPT ADVICE FROM MY-NAME-FOR-DOLLAR-QQQ.
The compiler accepts this form of the ACCEPT statement only if it has already encountered an entry
in the SPECIAL-NAMES paragraph associating MY-NAME-FOR-DOLLAR-QQQ with some device
or process; for example:
SPECIAL-NAMES.
FILE "$QQQ" IS MY-NAME-FOR-DOLLAR-QQQ.
Each time an ACCEPT statement in a process executes, the process opens the terminal or process,
collects the characters, and closes the terminal or process. Some other process could open the
terminal or process for exclusive use and hold it open, causing the next ACCEPT or DISPLAY
statement that tries to reach it to get a “device in use” error.
Reading and Writing Numeric Data
The ANSI standard is not very specific on the details of the behavior of ACCEPT. The ACCEPT
statement, as implemented in HP COBOL, allows you some flexibility in entering numeric data that
some other implementations do not.
HP COBOL allows you to enter a sequence of characters that correspond to a numeric literal, such
as would be legal in an HP COBOL source program. The ACCEPT run-time routine converts this
numeric representation into an appropriate form for storage in the designated data item, only as
if you had a MOVE statement that specified the numeric literal as its source and the data item as
its destination.
The DISPLAY statement is equally versatile, converting a stored data value to a convenient external
format. In Example 295, both ACCEPT and DISPLAY handle signed and unsigned numeric, numeric
edited, and computational items.
896 Terminal Input and Output