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

29 Terminal Input and Output
Most interaction between users and an HP system is conducted through video display terminals.
The HP COBOL language has no mechanisms for full-screen block input-output. On an HP system,
a typical application uses Pathway/TS to write requester programs in SCREEN COBOL to handle
terminal input and output and uses HP COBOL or pTAL server programs to handle database input
and output. Occasionally, an HP COBOL process must communicate with a terminal directly.
For very small amounts of data transfer and for free-format collection and reporting of numeric
values, such processes can use the ACCEPT and DISPLAY statements. Each ACCEPT or DISPLAY
statement either specifies a mnemonic name of a device or defaults to the process’s IN or OUT
file, respectively (only if the IN and OUT files are suitable for ACCEPT and DISPLAY statement use).
If a process needs uninterrupted access to a terminal or wants to determine at run time which of
several terminals to communicate with, the process must declare the terminal process as a sequential
file and operate on it with the usual OPEN, READ, WRITE, and CLOSE statements.
The system generation process includes operations to define each terminal attached to an HP
system. Each terminal has a device name and a logical device number.
The file system supports transfers from terminals in both page mode and conversational mode.
Conversational mode is easy to use from an HP COBOL process, but page mode is awkward. The
normal way to use page-mode input and output in conjunction with an HP COBOL process is to
write a SCREEN COBOL requester program and have it communicate with an HP COBOL server
process.
Using ACCEPT and DISPLAY With a Terminal
ACCEPT and DISPLAY statements transfer small amounts of data between a device and a process.
The device is not a file; it is neither mentioned in the HP COBOL program’s FILE-CONTROL
paragraph nor described in the program’s File Section.
Whenever a process executes an ACCEPT or DISPLAY statement, the HP COBOL run-time routines
automatically open the device, perform the operation, and close the device.
Any ACCEPT and DISPLAY statements that do not include a mnemonic name to specify a device
interact with the standard input and output devices of their process, respectively.
Guardian Environment
In the Guardian environment, each process has an IN file, an OUT file, and a home terminal file.
You can specify these files in the RUN command, using the IN, OUT, and TERM run options or
with the PARAM EXECUTION-LOG command (see Chapter 25: Executing and Debugging
HP COBOL Programs (page 820)). If you do not specify one or all of the files in the RUN command,
the process inherits the corresponding file of the command interpreter that accepted the RUN
command.
If you want a process’s ACCEPT and DISPLAY statements to interact with a terminal other than that
on which you issued the RUN command to start the process, you have two alternatives:
Use the SPECIAL-NAMES paragraph to associate a mnemonic name with the other terminal
and qualify the ACCEPT and DISPLAY statements with that name.
Mention the other terminal in the RUN command IN and OUT options when you initiate the
process.
If a process needs to choose among several terminals for input or output, the use of the mnemonic
name requires that all device assignments be established at compile time; therefore, several ACCEPT
or DISPLAY statements, each associated with a fixed device, must be present in the program, and
the process must choose the ACCEPT or DISPLAY to use.
Using ACCEPT and DISPLAY With a Terminal 889