PRINTER statement

Syntax

PRINTER { ON | OFF | RESET }
PRINTER CLOSE [ON print.channel]

Description

Use the PRINTER statement to direct output either to the screen or to a printer. By default, all output is sent to the screen unless a PRINTER ON is executed or the P option to the RUN command is used. See the SETPTR command for more details about redirecting output.

PRINTER ON sends output to the system line printer via print channel 0. The output is stored in a buffer until a PRINTER CLOSE statement is executed or the program terminates; the output is then printed (see the PRINTER statement CLOSE statement).

PRINTER OFF sends output to the screen via print channel 0. When the program is executed, the data is immediately printed on the screen.

The PRINTER ON or PRINTER OFF statement must precede the PRINT statement that starts the print file.

Use the PRINTER RESET statement to reset the printing options. PRINTER RESET removes the header and footer, resets the page count to 1, resets the line count to 1, and restarts page waiting.

Note: Use TPRINT statement to set a delay before printing. See also the TPARM function statement.

The PRINTER CLOSE Statement

Use the PRINTER CLOSE statement to print all output data stored in the printer buffer.

You can specify print channel -1 through 255 with the ON clause. If you omit the ON clause from a PRINTER CLOSE statement, print channel 0 is closed. Only data directed to the printer specified by the ON clause is printed. Therefore, there must be a corresponding PRINTER CLOSE ON print.channel for each ON clause specified in a PRINT statement. All print channels are closed when the program stops. Logical print channel -1 prints the data on the screen, regardless of whether a PRINTER ON statement has been executed.

If print.channel evaluates to the null value, the PRINTER CLOSE statement fails and the program terminates with a run-time error message.

In PICK, IN2, and REALITY flavor accounts, the PRINTER CLOSE statement closes all print channels.

Example

PRINTER ON
PRINT "OUTPUT IS PRINTED ON PRINT FILE 0"
PRINTER OFF
PRINT "OUTPUT IS PRINTED ON THE TERMINAL"
*
PRINT ON 1 "OUTPUT WILL BE PRINTED ON PRINT FILE 1"
PRINT ON 2 "OUTPUT WILL BE PRINTED ON PRINT FILE 2"

This is the program output:

OUTPUT IS PRINTED ON THE TERMINAL