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

Example 290 shows the use of ACCEPT and DISPLAY statements with the IN file and the OUT file
and with a terminal that is known to the file system as $TRM053.
Example 290 ACCEPT and DISPLAY Statements With a Terminal
IDENTIFICATION DIVISION.
PROGRAM-ID. TERMINAL-ACCEPT-DISPLAY.
AUTHOR. MO COBOL.
DATE-WRITTEN. 29 FEBRUARY 1984.
DATE-COMPILED.
******************************************************
* This program illustrates ACCEPT and DISPLAY with *
* and without mnemonic names. *
******************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. HP TXP.
OBJECT-COMPUTER. HP TXP.
SPECIAL-NAMES.
FILE "$TRM053" IS OUT-THERE.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A-TEXT-LINE PICTURE X(30).
PROCEDURE DIVISION.
A.
* Deliver a value to the default terminal (the OUT file)
DISPLAY "Who's there?".
* Get a line from the default terminal (the IN file)
ACCEPT A-TEXT-LINE.
* Deliver the entered-line from the default terminal to
* OUT-THERE
DISPLAY A-TEXT-LINE " is at the default terminal."
UPON OUT-THERE.
* Deliver a value to a specific terminal
DISPLAY "Who's there?" UPON OUT-THERE.
* Get a line from a specific terminal
ACCEPT A-TEXT-LINE FROM OUT-THERE.
* Deliver the entered-line from OUT-THERE
DISPLAY A-TEXT-LINE " is at terminal $TRM053".
STOP RUN.
OSS Environment
These are true in the OSS environment but not in the Guardian environment:
No prompt is given for an ACCEPT statement.
If a DISPLAY statement includes mnemonic-name, it must be either the OSS pathname of a
Guardian file or the name of an OSS text file.
If an ACCEPT statement includes mnemonic-name, it must be the OSS pathname of a
Guardian process or terminal. If mnemonic-name is an OSS device, a diagnostic is issued
and the default input device (#IN) is used instead.
Using a Terminal as a File
All files that an HP COBOL process uses must be specified in the FILE-CONTROL paragraph and
described in the File Section of the Data Division of the source program.
As with any other file, the process must explicitly open the terminal file, perform its read and write
operations, and close the file.
It is always advisable to declare a terminal file to have variable-length records by including a
RECORD CONTAINS or RECORD IS VARYING clause in the file description of the file. If the file
is not declared to have variable-length records, the HP COBOL run-time routines expect each READ
890 Terminal Input and Output