Using @ ... SAY Commands & Control Codes to Print in FP/WLast reviewed: October 18, 1996Article ID: Q99595 |
The information in this article applies to:
SUMMARYThe following procedures show how to bypass the Windows printer drivers and send control codes directly to the printer for use in combination with @ ... SAY commands.
MORE INFORMATIONFoxPro for Windows cannot send control codes directly to a printer using a Windows printer driver. There are two techniques to work around this:
The following examples send control codes to switch an Epson FX-80 dot- matrix printer's compressed mode on and off. NOTE: When using these techniques, do not use any of the ? or ?? commands for output. Only use @ ... SAY commands.
Technique 1: Open the Printer in Raw ModeThere are two ways to open the printer in raw mode:
SET DEVICE TO PRINT SET PRINTER TO ??? " " @ 1,0 SAY 'NORMAL TEXT' @ 2,0 SAY CHR(15) && Control code to turn compressed mode on @ 2,0 SAY 'CONDENSED text?' @ 3,0 SAY CHR(18) && Control code to turn compressed mode off @ 3,0 SAY 'NORMAL again' SET DEVICE TO SCREEN SET PRINTER TONOTE: In some circumstances, the last @ ... SAY command may not print. If this problem occurs, add an additional @ ... SAY command that prints a blank line (so that the lost line is just a blank). If adding a blank line is not an acceptable workaround, use one of the other methods listed in this article. Use the SET PDSETUP TO <Driver Name> Command: NOTE: This method will not work under Visual FoxPro unless the FoxPro 2.x file, GENPD.APP, exists. Visual FoxPro does not ship with GENPD.APP, which means that if you want to use GENPD.APP with Visual FoxPro, you must first convert and rebuild it under Visual FoxPro.
SET PRINTER TO SET PDSETUP TO "Epson" SET DEVICE TO PRINT @ 1, 0 SAY 'NORMAL text' @ 2, 0 SAY CHR(15) && Control code to turn compressed mode on @ 2, 0 SAY 'CONDENSED text' @ 3, 0 SAY CHR(18) && Control code to turn compressed mode off @ 3, 0 SAY 'normal again' SET DEVICE TO SCREEN SET PRINT TO Technique 2: Write to Text File and Copy to Printer Port
SET DEVICE TO FILE output.prn @ 1,0 SAY 'NORMAL text' @ 2,0 SAY CHR(15) && Control code to turn compressed mode on @ 2,0 SAY 'CONDENSED text' @ 3, 0 SAY CHR(18) && Control code to turn compressed mode off @ 3, 0 SAY 'Back to normal text' SET DEVICE TO SCREEN SET SAFETY OFF COPY FILE output.prn TO lpt1.dos SET SAFETY ONMore Information About Printing to LPT1.DOS: When Windows prints to a file named LPT1.DOS, MS-DOS interprets the request to open the file LPT1.DOS as a request to send data to the printer port, and it sends the data out through its own printing handler. Because Windows thinks that LPT1.DOS is an MS-DOS file, the Print Manager is not used. For more information about this topic, please see the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q68652 TITLE : Printing to Windows LPT1.OS2 or LPT1.DOS Port ARTICLE-ID: Q82749 TITLE : Using LPT1.OS2, LPT1.DOS, or FILE: Ports When Printing |
Additional reference words: 5.00 VFoxWin 3.00 FoxWin 2.50 2.50a 2.50b 2.60
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |