Spooler Plus Programmer's Guide
Using the Spooler Interface Procedures
Spooler Plus Programmer’s Guide—522293-003
2-10
Summary of Spooling From an Application Program
Example of a Level-3 Application Program
You send data to the spooler at level 3 in 5 steps:
1. Open a file to a collector with the file-system OPEN procedure. This file must be
opened with waited I/O.
2. Call SPOOLSTART, including the level-3-buffer parameter.
3. Send data to the collector with calls to the SPOOLWRITE, SPOOLCONTROL,
SPOOLCONTROLBUF, and SPOOLSETMODE procedures. As noted earlier, not
all calls to these procedures actually write data to the spooler. However, the
blocking of data is transparent to the user.
4. The application signals the end of the job by calling the SPOOLEND procedure.
Because you call SPOOLEND instead of the file-system CLOSE procedure to
close the file, you can begin spooling another job without reopening a file to the
collector.
5. At the end of the program run, close the collector file.
Example 2-3
is an example of level-3 spooling.
! Open file to collector, and check for errors.
CALL OPEN( collector, collectnum);
IF <> THEN CALL error;
! Call SPOOLSTART to specify job's attributes
! location #LPRMT3
! form name blanks (default)
! report name user's name and group name (default)
! number of copies 1 (default)
! page size 40
! flags
! hold off
! holdafter on
! NonStop bit off
! priority 7
sperrnum := SPOOLSTART(collectnum,,location,,,,
40,%B0000000000100111);
! Test for an error from SPOOLSTART
IF sperrnum THEN CALL sperror(sperrnum);
! Get a line of data and test for done.
! If done, fall through.
WHILE getline(line, length) DO
BEGIN
! Write the line to the collector and test for errors
CALL WRITE ( collectnum, line, length);
IF <> THEN CALL error;
END;
! Close the file to the collector and stop the program
CALL CLOSE(collectnum);
IF <> THEN CALL error;
CALL STOP;
END;
Example 2-2. Annotated Example of Level-2 Spooling (page 3 of 3)