Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Escape Codes to Printer

Status
Not open for further replies.

BongoB1

Programmer
Jul 26, 2001
26
0
0
US
I have a file that contains a long list of escape codes and printer codes that produces the image of a tax form on blank paper when copied directly to the printer. I would like to see about sending this to the printer from the top of a FoxPro form so that I can also fill in the data boxes using the form. I've tried different combinations of storing the file contents in memo and general fields or reading the file contents into a memory variable. Instead of acting on the escape character, the laser printer simply prints boxes. I am running Windows 2000 to an HP laser printer using VFP 6.0.

Any thoughts would be appreciated.
 
I would suggest that you give up. Unless you have many of these forms that need to be printed that way, you would be better off redrawing them using the report writer. It isn't that hard to reproduce a form. You could probably spend a day or so and have it finished.
If that isn't an option, you'll have to determine where in the long list the fields belong, and print them in the proper sequence. That will probably be more time consuming that redoing it.
Anyway, to print the stuff, you need to somehow get it into a format VFP can use. For instance, if your file consists of something like ^[xx codes, you need to convert them to the character values and print them using '???'. If ^[xx equals Esc+b, then convert to CHR(27) + 'b':

???CHR(27) + 'b'

and so on.




-Dave S.-
[cheers]
Even more Fox stuff at:
 
Thanks. I was hoping to be able to send the contents of this file to the printer like the old days when you sent escape codes but it doesn't look like that is going to be possible.

Thanks again for the advice.
 
Well, you can still send escape codes, they just have to be sent by Fox as the actual character values. There are a lot of reports out there that were written in the DOS days that folks don't want to take the time to rewrite with the report writer. These still work when sent to the printer in raw format using the '?', '??' or even '???' commands. For example. Say you have a table of names and addresses. You can print a report using code something like:
Code:
SET CONSOLE OFF
SET PRINTER ON PROMPT
SET DEVICE TO PRINTER

STORE CHR(27) + "(s3B" TO cBoldOn
STORE CHR(27) + "(s0B" TO cBoldOff

STORE .T. TO lDoHeader
SCAN 
   STORE 2 TO nlines
   IF lDoHeader
      ?cBoldOn
      ?'Name                     Address'
      ?'------------------------ ---------------------------'
      ??cBoldOff
      lDoHeader = .F.
   ENDIF
   ?MyTable.Name + MyTable.Address
   .
   .
   .
   nlines = nlines + 1
   IF nlines > 60 
      lDoHeader = .T.
   ENDIF
ENDSCAN 

SET DEVICE TO SCREEN
SET PRINTER OFF
SET PRINTER TO
SET CONSOLE ON


-Dave S.-
[cheers]
Even more Fox stuff at:
 
You might try loading the file to the printer before hand as a template. Most lasers have the capabilty to do that. Then you would only need to send 1 escape sequence to select the template. While I have not done this in a while I have done it in the past.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top