xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

SET PRINTER

Enables or disables output to the printer or redirects printer output.

Syntax

SET PRINTER on | OFF | ( <lOnOff> )

or

SET PRINTER TO [<cDevice> | <cFile> [ADDITIVE]]

Arguments

on | OFF | ( <lOnOff> )
This option toggles whether console output is also directed to the printer or not. The default is OFF or .F. (false), i.e. the printer does not receive console output. To change the setting use ON or .T. (true) as parameter. The parameter can also be specified as a logical expression enclosed in parentheses.
TO <cDevice>
<cDevice> is the name of the device where all console output will be copied to. The device can be local or on a network. If the device name does not exist, a file with the name <cDevice> is created. The device name can be specified as a literal character string or as a character expression enclosed in parentheses.
TO <cFile>
<cFile> is the name of the output file. The name of the file can be specified as a literal character string or as a character expression enclosed in parentheses. The default file extension is PRN.
ADDITIVE
This option causes print output to be appended to the file <cFile>. When ADDITIVE is omitted, the file <cFile> is created as a new, empty file.

If SET PRINTER TO is specified without any argument, the currently specified device or file is closed and the default destination is reselected.

Description

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.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe