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"
30   PRINTER IS F$,WIDTH(80)
40   SYSTEM PRINTER IS F$"1",WIDTH(132)
50   PRINT ALL IS "SPOOLA"D$
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)
30   PRINT LIN(5),SPA(25);"RIPPLE PRINT",LIN(1)
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
 !"#$%&'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
!"#$%&'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_a
"#$%&'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ab
#$%&'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abc
$%&'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcd
%&'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcde
&'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdef
'()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefg
()*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefgh
)*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghi
*+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghij
+,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijk
,-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijkl
-./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklm
./0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmn
/0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmno
0123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnop
123456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopq
23456789:;%<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqr

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