COBOL Manual for TNS and TNS/R Programs

Terminal Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
29-4
OSS Environment
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 statement to receive a record of
exactly the length declared (explicitly or implicitly) in the file description, and they raise
a run-time error if too short a record is typed at the terminal. If a record of more than
the declared number of characters is typed at the terminal, the run-time routine does
not deliver the excess characters to the process.
When an HP COBOL process opens a file assigned to a terminal, it establishes
communication with that terminal. The default exclusion mode for terminals is
SHARED. If a process is to have private use of a terminal, with no command
interpreter assigned to the terminal, the OPEN statement should specify the exclusion
mode EXCLUSIVE.
Use the ASSIGN clause of the file-control entry for a given file to associate a COBOL
file name with a device name or logical device number of a terminal. You can override
this assignment at the start of a process’s execution by using the TACL command
ASSIGN. Establish the assignment dynamically during process execution by specifying
#DYNAMIC in the ASSIGN clause of the file-control entry and calling the
COBOLASSIGN routine (in the non-CRE environment) or the COBOL_ASSIGN_
routines (in the CRE) to associate the terminal device name or logical device number
with a COBOL file name.
Example 29-2 shows the use of terminal $TRM053 as a file.