xHarbour Reference Documentation > Command Reference |
Enables or disables output to the printer or redirects printer output.
SET PRINTER on | OFF | ( <lOnOff> ) or SET PRINTER TO [<cDevice> | <cFile> [ADDITIVE]]
If SET PRINTER TO is specified without any argument, the currently specified device or file is closed and the default destination is reselected.
The SET PRINTER command has two different functionalities.
The ON | OFF form of SET PRINTER determines if the console output is echoed to the printer. Commands that send output to the console are called console commands. Console commands, in general, do not specify row and column coordinates. All these commands (with exception of the ? and ?? command) have a TO PRINTER clause which echoes the console output to the printer. The output from the console commands is displayed on the console window, unless CONSOLE is OFF.
The SET PRINTER command determines destination of output from all commands and functions that send output to the printer. This includes the @...SAY command if device is set to printer. If the destination is a device, the names LPT1, LPT2, LPT3 (all parallel ports), COM1 and COM2 (serial ports), CON and PRN are valid. Default device is PRN.
When the destination is a file, it is created in the current default directory. When a file with the same name already exists, it is overwritten by the new one. No warning is generated when overwriting the file. Until the file is closed with SET PRINTER TO (with no argument), all output is echoed to this file.
Notes
The @...SAY command is not affected by SET PRINTER ON. To send the output of this command to the printer, use the SET DEVICE TO PRINTER instead.
Using the Windows operating system, xHarbour supports the SET PRINTER TO \\ServerName\PrinterName syntax.
When the file is closed, no end of file marker is added. To add the end of file marker, use ?? Chr(26) just before the closing the file with SET PRINTER TO and no argument.
See also: | @...SAY, EJECT, PCol(), PRow(), Set(), SET ALTERNATE, SET CONSOLE, SET DEVICE, SetPrc() |
Category: | Console commands , Printer commands , SET commands |
Source: | rtl\console.c, rtl\set.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example echoes the output of the ? command to printer: PROCEDURE Main USE Employees NEW SET PRINTER ON DO WHILE !EOF() ? Employees->Name, Employees->Phone SKIP ENDDO EJECT SET PRINTER OFF CLOSE RETURN
http://www.xHarbour.com