GetPrinter(), PrtInfo(), Sys(1037)
These three functions are a wonderful relief from the printing challenges of early FoxPro versions. GETPRINTER() presents the Windows dialog to choose the printer for output, PRTINFO() allows the programmer to query all the details of the capabilities of the printer, and SYS(1037) puts up a decent Print Setup dialog.
Usage |
cPrinterChosen = GETPRINTER( ) |
Parameter |
Value |
Meaning |
cPrinterChosen |
Character |
The name of the printer chosen. |
Empty String |
User chose Cancel, or closed the dialog box any way other than selecting OK. |
Example |
cPrinter = GETPRINTER() IF NOT EMPTY(cPrinter) SET PRINTER TO NAME (cPrinter) ENDIF |
Usage |
nResult = PRTINFO( nIndex [, cPrinterName ] ) |
Parameter |
Value |
Meaning |
nIndex |
1 |
Orientation. |
2 |
Paper size. If –1 is returned, use parameters 3 and 4 to determine the custom paper size. |
|
3 |
Paper length, in tenths of a millimeter. |
|
4 |
Paper width, in tenths of a millimeter. |
|
5 |
Scaling factor. |
|
6 |
Number of copies to print. |
|
7 |
Paper tray chosen as the default paper source. |
|
8 |
Print quality, expressed in dots per inch, if a positive number, or a relative scale (Draft, Low, Medium, High) if a negative number (–1 to –4, respectively). |
|
9 |
Color printing? 1=Color, 2=Single color. |
|
10 |
Printer duplexing (printing both sides of the page) mode. |
|
11 |
Vertical resolution, in dots per inch. |
|
12 |
Options for printing TrueType fonts. |
|
13 |
Whether or not output is collated. |
|
cPrinterName |
Character |
The name of the printer, as returned by GETPRINTER() and APRINTERS(). |
nResult |
–1 |
With two exceptions noted above (paper size, number 2 and print quality, number 8), a negative return indicates the information is unavailable. Either this feature may not be implemented for this printer, or you may have specified a printer that doesn't exist. |
Integer |
Result of querying the particular parameter above, as documented above and in the help file. |
Example |
* Note that the following must be compiled * to include FoxPro.H and run properly. #INCLUDE \VFP\FOXPRO.H ? "Orientation: " nResult = PRTINFO(PRT_ORIENTATION) DO CASE CASE nResult = -1 ?? "Not Available" CASE nResult = 0 ?? "Portrait" CASE nResult = 1 ?? "Landscape" ENDCASE |
Usage |
cEmptyString = SYS( 1037 ) |
The documentation erroneously claims that SYS(1037) brings forth a Page Setup dialog, and it even links to a description of the Page Setup dialog. However, calling this function brings up a dialog labeled "Print Setup," which is obviously not the Page Setup dialog. In the Print Setup dialog, the Properties button does allow you to adjust the default paper size, orientation and other settings specific to your printer. And it works just fine, unless you've tinkered with the Page Setup option from the menu while creating or editing your report. If you want to give the user the ability to use his SYS(1037) settings instead, you need to delete the stored settings from the report. They're in TAG and TAG2 of the first record of the FRX—you can use something like this: SYS(1037) SELECT * FROM MyReport.FRX INTO CURSOR TempReport SELECT TempReport BLANK FIELDS TAG, TAG2 REPORT FORM TempReport TO PRINT |
Example |
=SYS(1037) |
See Also |