Spooler Programmer's Guide

Sample Print Process
Spooler Programmer’s Guide522287-002
A-21
! procedure to process the spooler supervisor command.
!
! DEVICE WRITE COMPLETIONS:
! ERROR:
! When the device write completes in error, the spooler
! supervisor is notified. This notification also
! indicates whether the previous device write was
! successful. This information is used for retryable type
! errors. The "suspend" flag is set to true to indicate
! that the current print job has been suspended. The
! "suspended" flag is also set to true to indicate that
! the current print job was suspended due to an error.
! When the "suspended" flag is true, the record that
! resulted in the write error is returned by
! PRINTREAD, versus PRINTREAD returning the next record
! ("suspend" flag = true and "suspended" flag = false).
!
! When the error is retryable, the spooler supervisor
! sends a RESUME command to the print process, where
! the job resumes printing with the record whose
! write previously failed.
! SUCCESSFUL:
! When the device write successfully completes, the
! "successful^op" flag is set to true, indicating a
! successful I/O occurred. If there is an active print
! job (not suspended), control is passed to the procedure
! READ^AND^PRINT, where the printing of the job is
! continued.
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PROC main^loop;
BEGIN
INT control, ! Parameter returned by PRINTREADCOMMAND
.device[0:11] := 12 * [" "],
dev^flags,
dev^param,
dev^width,
skip^num,
.data^file^name[0:11] := 12 * [" "],
job^num,
.location[0:7] := 8 * [" "],
.formname[0:7] := 8 * [" "],
.reportname[0:7] := 8 * [" "],
page^size,
fnum,
error;
INT(32) timeout;
LITERAL next^line = 0;
!---Beginning of code--------------------------------------------------
WHILE 1 DO
BEGIN
fnum := -1;
! If the device is not open, wait 2 minutes before stopping.
! During this time the spooler can ask the user to start a new
! job without having to fire up a new process.
IF dev^fnum = 0 THEN
timeout := 12000D ! 2 minutes
ELSE
timeout := -1D; ! forever
CALL AWAITIO (fnum,,,, timeout);
CALL FILEINFO (fnum, error);
IF error = 40 then ! No completion within time limit,
CALL STOP; ! must be time to stop
IF fnum = dev^fnum THEN