Set Printer, Set("Printer"), Sys(102),
Sys(6)
SET PRINTER is another "can of oil" command—three in
one. It lets you send output to the printer, choose a printer for
output, and specify a default font for output. The functions
provide information about the current print setup.
Usage
|
SET PRINTER ON [ PROMPT ] | OFF
SET PRINTER TO [ FileName [ ADDITIVE ] | DEFAULT
| NAME WindowsPrinterName | \\MachineName\PrinterName ]
SET PRINTER FONT cFontName [, nFontSize ] [ STYLE cStyleCodes ]
|
We've never used the full name of this command. In fact,
we've never seen SET PRINTER anywhere but in the documentation.
It's universally called SET PRINT (although IntelliSense expands
it to SET PRINTER).SET PRINT ON starts queuing output for the
current printer. SET PRINT OFF stops queuing output. The queued
output is actually sent to the printer (well, to Print Manager
anyway) by issuing SET PRINT TO without anything after it.
|
SET PRINT ON PROMPT brings up the printer setup dialog
only some of the time. PRINT has to be OFF. If it was
previously ON, both SET PRINT OFF and SET PRINT TO have to
run, in that order, before FoxPro pays attention to the
PROMPT clause. This is true even if the user cancels out of
the printer setup dialog.
|
In addition, you have to have at least one printer installed to
use the PROMPT clause; with no printers installed (as, say, on a
notebook that's never used for printing), using the PROMPT clause
brings up a pair of error messages. Check NOT
EMPTY(APRINTERS(laTemp)) to make sure a printer is available.The
various forms of SET PRINT TO route output to different places.
You can specify a filename, the Windows default printer, a
specific Windows printer or, in networks that support the
Universal Naming Convention (UNC), a specific network printer. (A
couple of other forms aren't relevant in Windows, so we've
omitted them from the syntax diagram.)Finally, SET PRINT lets you
establish a default printer font that's used when you don't
specify a font for an output item.Normally, SET PRINT affects
only output from ? and ?? and commands with the TO PRINT clause,
but combined with SET DEVICE, you can also redirect @ .. SAY
output.
Usage
|
cOnOrOff = SET( "PRINTER" ) | SYS(102)
cPrintFile = SET( "PRINTER", 1 ) | SYS(6)
cCurrentPrinter = SET( "PRINTER", 2)
cDefaultPrinter = SET( "PRINTER", 3)
|
The functions tell you the current state of printer
affairs. It takes several of them together before you can figure
out where output is likely to go at this moment. SET("PRINT") by
itself just tells you "ON" or "OFF". So far, so good.
SET("PRINT",1) and SYS(6) tell you if you've SET PRINT TO a file,
including a UNC file name, or if you've SET PRINT TO a port (like
SET PRINT TO LPT1). SET(PRINT",2) and SET("PRINT",3) tell you
about default printers. SET("PRINT",2), added in VFP 5, tells you
about the Windows default printer. Finally, SET("PRINT",3), added
in VFP 6, tells you which printer VFP considers its default
(current destination) printer.
Example
|
SET PRINT TO DEFAULT
SET PRINT ON
? "This is a test of the emergency printer system."
? "This is only a test."
? "In the event of a real emergency, these words would"
?? "be much larger and louder."
SET PRINT OFF
SET PRINT TO
SET PRINT TO Test.Txt
SET PRINT ON
? SET("PRINT")
? SET("PRINT",1)
SET PRINT TO NAME "\\MyServer\HP LaserJet 4M Plus"
APRINTERS(laPrinters)
SET PRINT TO NAME laPrinters[1, 1]
|
Back to Table of Contents
Copyright © 2002-2018 by Tamar E. Granor,
Ted Roche, Doug Hennig, and Della Martin. Click for license
.