SET PRINTER Command
Enables or disables output to the printer or routes output to a file, port, or network printer. There are several versions of the syntax.
To direct output to a file, a port for a different local printer, or a network printer, use SET PRINTER TO with the specified arguments. To reset output to the default MS-DOS PRN print utility, use SET PRINTER TO without arguments.
SET PRINTER ON [PROMPT] | OFF
SET PRINTER FONT cFontName [, nFontSize [, nFontCharSet]] [STYLE cFontStyle]
SET PRINTER TO [FileName [ADDITIVE] | PortName]
SET PRINTER TO [DEFAULT | NAME WindowsPrinterName]
SET PRINTER TO NAME \\ServerName\PrinterName
- ON [PROMPT]
Enables output to the printer.
PROMPT displays the Print dialog box before printing starts. In the Print dialog box, you can adjust printer settings. The currently installed printer driver determines which printer settings you can adjust.
When SET PRINTER is set to ON, output formatted with the @ ... SAY command is not routed to the printer. To direct output from @ ... SAY to the printer, use the SET DEVICE TO PRINTER command. For more information, see SET DEVICE Command.
Disables output to the printer. (Default)
- FONT cFontName[, cFontSize [, nFontCharSet]]
Specifies a default font for printer output. cFontName specifies the name of the font, and cFontSize specifies the point size. You can specify a language script with nFontCharSet. See the for a list of available language script values.
For example, the following command specifies 16-point Courier font as the default printer font:
SET PRINTER FONT 'Courier', 16
If the font you specify is not available, a font with similar font characteristics is substituted.
- STYLE cFontStyle
Specifies a default font style for printer output. If you omit the STYLE clause, the normal font style is used. If the font style you specify is not available, a font style with similar characteristics is substituted.
The following table lists font styles you can specify with cFontStyle.
cFontStyle Font style
You can include more than one character to specify a combination of font styles. For example, the following command specifies 16-point Courier Bold Italic:
SET PRINTER FONT 'Courier', 16 STYLE 'BI'
- TO [ FileName[ADDITIVE] | PortName]
Specifies a file or port to which output is directed.
FileName specifies a file name to which output is directed.
ADDITIVE appends output to the existing contents of the file. Omitting ADDITIVE overwrites the existing contents of the file.
PortName sends output to a different local printer.
- TO [DEFAULT | NAME WindowsPrinterName]
Sends printer output to the default Windows printer or to a specific Windows printer.
Windows printer names are stored in the Win.ini file.
- TO NAME \\ ServerName\ PrinterName
Spools printer output to a network printer.
This clause is supported only for versions of Visual FoxPro running on Windows 2000 or later.
ServerName is the network name assigned to the print server. This name is assigned by the network administrator and must be unique.
PrinterName is a name that is assigned to the printer and by the network administrator.
When you direct output to a network printer, output prints or collects in a print spooler until a new SET PRINTER command is issued. For additional information about printing on your network, consult your network documentation.
This command does not function in Unattended Server Mode.
You can use the GETPRINTER( ) or APRINTERS( ) functions to determine the names of the currently installed printers. For example, the following command displays the Windows Printer dialog box and makes the printer you select the printer to which printed output is directed:
SET PRINTER TO NAME GETPRINTER( )