COBOL Manual for TNS and TNS/R Programs

Terminal Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
29-8
Terminal Associated With a Command Interpreter
Terminal Associated With a Command Interpreter
When a command interpreter has a terminal open for its IN and OUT file, an
HP COBOL process can open that terminal as a file only if it opens it for shared access
(the default). It cannot open such a terminal for exclusive access, even if the command
interpreter does not accept messages from or send messages to that terminal for the
duration of the HP COBOL process’s execution. If you want an HP COBOL process to
have exclusive use of a terminal, no command interpreter can have the terminal open.
To free a terminal that is running TACL for use as a file by an HP COBOL program,
enter the TACL command PAUSE.
Terminal Not Associated With a Command Interpreter
When a terminal is not connected to a command interpreter, an HP COBOL process
can open it, read from it, write to it, or close it like any other file. See Using a Terminal
as a File.
Non-COBOL Modules
If your program consists of modules written in different languages, the modules can
share the standard files—the predefined files called “standard input,” “standard output,”
and “standard log” (except that FORTRAN modules cannot share “standard log”
because FORTRAN does not support it). The standard input, output, and log file can
be a terminal.
If you want to do mixed-language programming, compiling your program to run in the
CRE is highly recommended. Although mixed-language programming is possible in the
non-CRE environment, it is very limited because of incompatibilities between different
languages’ run-time libraries. The CRE supports the languages HP C, HP COBOL,
FORTRAN, Pascal, and TAL. For more information about the CRE in general and on
mixed-language programs sharing standard files in particular, see the CRE
Programmers Guide.
Getting Break Ownership
When you press Break on a terminal, the process that owns Break receives a system
message on $RECEIVE. A process discovers that Break has been pressed by reading
$RECEIVE. An HP COBOL process, lacking the ability to perform NOWAIT input and
output directly, must open $RECEIVE with an OPEN statement with a TIME LIMITS
phrase and then try to read $RECEIVE from time to time. If a READ statement fails
because it timed out, Break was not pressed.