9 Output Operations

Spool Files

When lack of a printer prevents running a program, spool files can be used in place of a printer. SPOOL (Simultaneous Peripheral Operations On Line) files allow rapid, temporary storage of printer output. Spool operations, however, do not relieve the CPU from eventually outputting the data to the printer. Using spool files reduces program execution time, since printer output is stored directly on a disk data file. The data can then be dumped to a printer or the display at your convenience.

Creating Spool Files

The three printer-control statements (PRINTER IS, PRINT ALL IS and SYSTEM PRINTER IS) are used to create a unique data file which holds all output of that type. The general syntax is as follows:

The optional WIDTH parameter specifies where to insert CRLFs in the output, as described at the start of this chapter. Once created, each spool file must not be accessed by other file storage operations (COPY, RENAME, PRINT#, etc.) until you have completed spooling into the file. Then reassign the printer-control function to another device (for example, PRINTER IS 8) to close the spool file.

Here is a program sequence which creates three spool files for later use:

10   F$="SPOOL"
20   D$=",SCR_PAD"
60   END

Recording into Spool Files

Once created, each spool file is automatically accessed by successive output operations of the appropriate type--PRINTER, SYSTEM PRINTER, or PRINT ALL. Only the significant characters of each line of output are recorded. CRLFs are automatically inserted according to the WIDTH parameter.

Dumping Spool Files

An abbreviated form of the COPY statement is used to output the contents of each spool file:

COPY file specifier

The contents of the spool file are dumped to the currently-specified printer of the same type assigned to the spool file. The current line width of the printer is ignored during the spool file dump.

Here is an example program which generates a 65-character-wide "ripple printout" of alphanumeric characters. The output is first spooled into a file called Ripple then dumped to the printer.

10 Makeripple:  !  output ripple to spool file.
20   PRINTER IS "Ripple",WIDTH(65)
40   C1=32
50   FOR Line=1 TO 32
60     FOR Char=C1 TO C1+64
70       PRINT CHR$(Char);
80     NEXT Char
90     C1=C1+1
100  NEXT Line
110 Dumpripple:  ! copy spool file to printer.
120  PRINTER IS 0,WIDTH(200)
130  COPY "Ripple"
140  END
Notice that the output can be duplicated as many times as needed by simply repeating the COPY statement.

                         RIPPLE PRINT

Appending to Spool Files

When an already-existing file is specified as a spool file, the computer attempts to append the spool file output onto the existing file.

Spool File Errors

Error codes 140 through 149 are reserved for spool file operations (refer to the error list in page 415 ). When one of these errors occurs, the spooling operation is terminated, and the display is automatically reassigned as the appropriate printing device (printer, print all or system printer).

Eloquence Language Manual - 19 DEC 2002