COBOL Manual for TNS and TNS/R Programs

Program Execution
HP COBOL Manual for TNS and TNS/R Programs522555-006
12-15
PARAM Command
The PRINTER-CONTROL parameter provides a way for the program to respond to
printer faults. Suppose a PRINTER-CONTROL parameter specifies the file name
CHEX. This causes the run-time library to keep track of each elementary control
function or write request that it sends to the operating environment for the file
CHEX. If one of those operations fails because the printer to which CHEX is
assigned is not ready, the WRITE statement completes with I-O status code “30”
(permanent error condition) and a GUARDIAN-ERR value of 100 (not ready) or
102 (out of paper).
To make use of the PRINTER-CONTROL parameter, the application program must
use a declarative procedure, preferably one of the form
USE AFTER STANDARD ERROR PROCEDURE ON CHEX
that responds only to errors on the printer file.
The procedure receives control when the operating environment detects the printer
problem. The procedure determines that the printers I-O status code is “30” and
handles the GUARDIAN-ERR values of 100 and 102. It might notify the operator of
which problem has occurred.
Although the record area still contains the record that was being written, there is no
way for the procedure to determine whether or not the record actually has been
written to the printer. For example, if “WRITE a-rec BEFORE ADVANCING PAGE”
was specified, perhaps the printer was off line before the write operation began, or
perhaps the record was written but the printer reached the end of the paper before
it could position to the top of a new sheet.
There is, however, a way to assure that the record does get written only once and
that any related control operations occur only once. The program must reissue
exactly the same form of the WRITE statement (same record name, same
ADVANCING clause, and so on). The run-time library does not repeat any control
function or system write request that successfully completed the first time, and re-
issues the control function or system write request that caused the status to occur,
plus any subsequent operations that were not completed.
One easy way to use this mechanism is to have the declarative respond to the
combination of I-O status code “30” and GUARDIAN-ERR value of 100 or 102 by
moving a FALSE value to a condition variable (associated to the condition-name
PRINT-OK) and conducting the dialog with the operator, then instead of coding just
a WRITE statement, code the sequence:
PERFORM UNTIL PRINT-OK
SET PRINT-OK TO TRUE
WRITE CHEX BEFORE ADVANCING 10
END-PERFORM