COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
the operation is an ACCEPT statement, the default values are returned to the receiving item.
In the case of tape mount messages, the run unit terminates abnormally.
• PRINTER-CONTROL Parameter
When an application program is writing to a printer, and the printer leaves the ready state
(perhaps it is out of paper or it is off line), the program does not automatically regain control.
The HP COBOL run-time library issues a message to the home terminal to report the printer
fault, and waits for the printer to be restored to the ready state.
In certain circumstances, the application program needs to regain control and take some
action when an active printer leaves the ready state. For example, the program might be
printing checks and keeping record of the preprinted check numbers issued to each payee.
The program asks the operator for the first check number in the sequence, then processes
checks depending on the number to increase by 1 each time. When the printer comes to the
end of a box of check forms (or suffers a paper jam and destroys some checks), the program
needs to be informed that a particular write operation was not completed routinely so that it
can ask the operator for the number of the next check it will be printing on.
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 printer’s 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
590 Program Execution










