PRINTER Statement

The PRINTER statement is necessary to redirect output to either the terminal display screen or the printer. By default, all output is sent to the terminal display screen unless a PRINTER ON statement is issued or the P option is used at runtime.

Format

PRINTER ON

PRINTER OFF

PRINTER CLOSE

Parameter(s)

PRINTER ON

Directs all subsequent program output sent by the PRINT, HEADING, FOOTING, or PAGE statements to a Spooler print unit. The contents of the print unit are printed when the program has terminated. If output is requested from the printer before program termination, the PRINTER CLOSE statement must be used to flush the output.

PRINTER OFF

Directs all subsequent program output immediately to the terminal display screen.

PRINTER CLOSE

Sends all contents of the print unit (that is, all output sent while the PRINTER ON statement was in effect) to the printer immediately.

Description

By default, all output is sent to print unit 0, which is immediately written to the terminal display screen unless the PRINTER ON statement is used. If the PRINTER ON statement is used, print unit 0 acts as a buffer to hold all output until the program has been terminated or until a PRINTER CLOSE statement has been used to flush out its contents. At that time the contents of print unit 0 is spooled to the printer.

The program output device may also be established at runtime. The TCL command RUN has an option, P, which allows the program to run as if a PRINTER ON statement had been issued at the beginning of the program.

The mvBASIC statement CRT (or DISPLAY), is identical to the PRINT statement except that it is not affected by the PRINTER statement. That is, all data which is output via the CRT statement is sent to the terminal display screen, regardless of whether the PRINTER ON statement has been used. This statement is designed to facilitate programs in which some output is sent to the terminal and some to the printer, since it allows printing to the terminal without toggling PRINTER OFF and PRINTER ON statements.

Example

To direct subsequent PRINT output to the printer, type:

PRINTER ON

The output is sent to print when the program is exited.

See Also

Statement and Function Reference