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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to send Esc code to Epson LQ-590II for draft, courier, etc. 1

Steve Yu

Programmer
Nov 6, 2021
129
US
Hello colleagues,


Above is an old thread that deals with exactly the same issue as I'm having now.
My code:

mpname = GETPRINTER()
SET PRINTER TO NAME &mpname
SET DEVICE TO print
SET PRINTER on
??? chr(27) + "x" + "0" && draft mode
??? chr(27) + "k" + "2" && courier
? "Hello World"
set printer to

The front panel display of Epson does not change, showing 'script' instead of USD or HSD.
Any output after that seems to resemble letter quality, not the draft mode I expected.
And the courier font does not seem to work either.

Help appreciated.
 
What is your Windows printer driver -- I think you have to use a Raw printer driver.
 
Hello colleagues,


Above is an old thread that deals with exactly the same issue as I'm having now.
My code:

mpname = GETPRINTER()
SET PRINTER TO NAME &mpname
SET DEVICE TO print
SET PRINTER on
??? chr(27) + "x" + "0" && draft mode
??? chr(27) + "k" + "2" && courier
? "Hello World"
set printer to

The front panel display of Epson does not change, showing 'script' instead of USD or HSD.
Any output after that seems to resemble letter quality, not the draft mode I expected.
And the courier font does not seem to work either.

Help appreciated.
Make sure that you use a printer driver that passes the data directly to the printer. It's called Generic, text only, or something like that.
 
Ditto. You need to use Generic Text Only printer drivers. Any device specific printer driver will not pass through ESC codes.
 
That did it.
Changed the driver from Epson to Generic/Text and the Esc code went through and reconfigured the fonts.
Thanks everyone.
One note: even I set Widows printer property to no spool (print direct), the print job still went to the print queue and won't go away until multiple 'set printer to', 'set printer off' commands. What is the exact command to end the print job ?
 
This might help.

As it talks of starting the print spooler service, finally, I wonder what you mean with a no spool printer property.

And what ends a print job you do with ??? after you SET PRINTER ON? I'd guess SET PRINTER OFF.

Or, if not, it would be one of the specific escape sequences you would send to your printer, wouldn't it?
 
Last edited:
This might help.

As it talks of starting the print spooler service, finally, I wonder what you mean with a no spool printer property.

And what ends a print job you do with ??? after you SET PRINTER ON? I'd guess SET PRINTER OFF.

Or, if not, it would be one of the specific escape sequences you would send to your printer, wouldn't it?
I'm familiar with start/stop procedures of spooler under Windows Services.
Here it seems I need to use Generic/Text as driver (vs Epson printer driver) and disable print spool; that's what I did by selecting 'Print directly to printer' instead of 'Spool print documents' under printer property.
My question was, with these settings, my print output went to the print queue anyway and stay there for sometime until I did a bunch of 'set printer off','set printer to'.
Maybe there is a time delay between 'set printer off' and when print jobs actually clear out of the queue; but it just seems to me they stay there for a very long time.
Maybe I'll try the printer reset Esc sequence at the end and see if it clears the queue.
 
It's been a while since I've needed to send ESC codes, but one thing that may make a difference is sending a FormFeed character when you want to eject a page.

In the old days, printers printed one line at a time. You sent a line, it printed the line right after the Carriage Return and Line Feed was sent.

When page based printers came along (laser and inkjets), they didn't start printing until either the page hit the last line, or you sent a FormFeed, CHR(12). That's because unlike line based printers, page based printers could define pages in any order by positioning items anywhere on the page, so they often wait until the FF to know when to print.
 
It's been a while since I've needed to send ESC codes, but one thing that may make a difference is sending a FormFeed character when you want to eject a page.

In the old days, printers printed one line at a time. You sent a line, it printed the line right after the Carriage Return and Line Feed was sent.

When page based printers came along (laser and inkjets), they didn't start printing until either the page hit the last line, or you sent a FormFeed, CHR(12). That's because unlike line based printers, page based printers could define pages in any order by positioning items anywhere on the page, so they often wait until the FF to know when to print.
Esc codes are used here primarily for printer font selection purpose for Epson LQ-590 dot-matrix printer (unfortunately we are still searching for laser alternatives for multi-part paper apps, or paperless options, but still, people need that piece of paper). The build-in Set Printer Font command in VFP does not seem to work (can't trigger draft mode for example). Even though the Set Printer Font does work for Okidata dot-matrix printers without need for any Esc codes.
Maybe that was the question I should have posted instead.
 
There is no direct printing, that should be clear by needing the Generic/Text Only driver. Your printer communication in Windows always goes through a driver and uses the whole Windows printer environment, i.e. print queue. Print queue and spooling are a tandem, they're not the same.

1740828457133.png
I'd set it that way. Isn't that an option in the driver settings?

Otherwise any ??? does neither finish a line nor a page, and even with a form feed (page feed) you're never defining the last page. So if you don't have these detailed options but only spooling or direct printing, I guess direct printing will still not mean immediate printing. I'd still say SET PRINTER OFF ends the job, maybe also SET PRINTER TO afterwards tells the printer and Windows you're done with that printer.
Maybe I'll try the printer reset Esc sequence at the end and see if it clears the queue.
Surely a good idea worth testing, I fear it would rather forget the whole print job, though.
 
Last edited:
Most printers today still respond to variations of the same coding languages they had for decades. The difference is how programs interact with them.

When I first started writing code around 1981, there was no such thing as a printer driver. You took the printer out of the box, and the book for the printer gave you a list of the codes to control things like font choices and sizes. The key here is that font choices had to be among those *built-in* to the printer.

You would need to know the specific fonts and sizes your printer supported and what codes changed them. The closest thing to a "driver" for me was tracking whether they had an Epson or Okidata printer in my own set of variables such as "FontBold", "FontNormal", "FontCondensed", etc., then swapping those variables based on a the printer they owned .

When graphic operating systems with unlimited fonts came along, they were able to ignore the limitations of the built-in fonts by making extensive use of the coding needed to send graphics, so instead of telling the printer to change to condensed, it could *draw* letters anywhere on the page alongside any other graphics with pixel perfect precision.

When you use the Generic Text Only printer driver, it fundamentally removes the ability to use things like SET PRINTER FONT that let Windows send any font you have installed to the printer and puts you back into the driver's seat when it comes to controlling the printer and using just the built-in font sizes.
 
Control-C is the ASCII code for End of File.

We've had quite a few responses, so I'm not sure which issues you are still having and which suggestions you tried. One thing I can say is that FormFeed, CHR(12) is definitely a universal command that tells a printer your page is complete, so it can start a new page, so if you haven't tried sending that, you may want to give it a try. EJECT should have the same effect.
 
Have you even sent a linefeed CHR(13)+CHR(10) or formfeed CHR(12)?

??? is like ?? in that respect, it does only send what you send, not like ? which prints to the active window with an automatic line feed added at the end, whereas ?? does not and ??? even less so. And ? "Hello World" in your initial post code will pirint that to the active windoiw (usually _screen), not the printer. So if you want to print using ??? then use ??? throughout. But then also don't SET DEVICE, that's only necessary when you want to print using @...SAY. Which would enable you to position texts, even out of order, because printing then is delayed anyway, until you finish, as it always is unclear where the next @..SAY should output something, that could be a previous line, even.

Even in direct and immediate printing a printer will only write out full lines, I think. Especially as you don't have a carriage anymore, that has a position, but a page oriented printer environment that prints at most line by line, if not only full pages. Neither a laser printer, an inkjet printer nor a thermo printer has a carriage that's positioned and prints with actual physical type faces like type writers have, or needles, I once had a needle printer, near letter quality, 1980s. The inkjet nozzles are closest to needles and toner is what's closest to an ink ribbon, but all ptriner types you use for computers except perhaps plotters just print lines as they come and so everything you want to print has to be completed at least on the level of lines, doesn't it?

Well, if not it would make all things much easier, including to configure what mode to print in with what embededded font, when using the EPSON printer driver(s).
 
Last edited:
Chris

We don't use linefeed,formfeed codes for printing anymore; only when we are building HTML or EDI text files.
We use ??? and ?? only for sending font settings Esc codes to Epson and we did not want the code to change print positions.
And the reason for using ??? is we are not able to put Epson into draft mode with the SET PRINT Font command.
 
Steve,

we were talking about how to finish the print job, weren't we? You tested printing "Hello, World", but did that with ?, not with ???, of course you'll never see anything when you don't even print to the printer. And then there are multiple suggestions by now, for which you didn't report back what you tried. Okay, you don't seem to get to a solution by interacting with us and giving feedback, so I just wish you all the best of getting this going.

VFP printing is not like DOS printing anymore, it's all going through the Windows printing system also with the Generic/ Text only driver. So you got to print control codes like linefeeds, when you want to see a line, even just ofr purpose of testing.

All in all the printer never can know when you're finished printing until you get to some code that actually ends it, SET PRINTER OFF didn't seem to do it, or it only did after a timeout, we never got any feedback from you about all we suggested. If you reject anything that's not your ESC codes for setting font and draft mode, then you're not understanding our recommendations at all, it seems.
 
Steve,

we were talking about how to finish the print job, weren't we? You tested printing "Hello, World", but did that with ?, not with ???, of course you'll never see anything when you don't even print to the printer. And then there are multiple suggestions by now, for which you didn't report back what you tried. Okay, you don't seem to get to a solution by interacting with us and giving feedback, so I just wish you all the best of getting this going.

VFP printing is not like DOS printing anymore, it's all going through the Windows printing system also with the Generic/ Text only driver. So you got to print control codes like linefeeds, when you want to see a line, even just ofr purpose of testing.

All in all the printer never can know when you're finished printing until you get to some code that actually ends it, SET PRINTER OFF didn't seem to do it, or it only did after a timeout, we never got any feedback from you about all we suggested. If you reject anything that's not your ESC codes for setting font and draft mode, then you're not understanding our recommendations at all, it seems.
Sorry, the testing is still in progress and very slow due to the fact I'm working from remote and have to work with people in the office, where the printer is located, who are not familiar with VFP printing so I'm only getting test results piece by piece and therefore wasn't able to report back yet.
As to ? and @ say commands used for dot-matrix printing, my opinion is they work mostly the same way after SET DEVICE TO PRINT and SET PRINT ON.
? 'Hello World' will cause a line feed before the text is sent to printer where @ 1,0 say 'New Page' will print the text on line 1, column 0; and a page eject will ensue if the previous print command was after @ 1,0 (for example @ 55,0 say 'End of Invoice') or before the current print position (which we will try to avoid) ; the @ say method is what we use for producing invoices and other forms that require duplicates. We'd use ?? and ??? to set the font only so they won't move or change the print position in combination with the @ say commands.
 
Okay. Well, you still have an answer or at least a hint why the ??? don't print immediately, if you SET DEVICE for using @..SAY the printer always is in a situation the page can't be considered complete, it will only all be printed once you end all output. So you still would do the font setting separately with ?? and then we're still back to everything you should try out. But mainly do that part without SET DEVICE TO PRINTER and after the font setting is in effect start the next print job the way you always do.
 
Okay. Well, you still have an answer or at least a hint why the ??? don't print immediately, if you SET DEVICE for using @..SAY the printer always is in a situation the page can't be considered complete, it will only all be printed once you end all output. So you still would do the font setting separately with ?? and then we're still back to everything you should try out. But mainly do that part without SET DEVICE TO PRINTER and after the font setting is in effect start the next print job the way you always do.
I'm now mostly certain the SET PRINTER TO will empty the print queue buffer as I recall years ago we had issue with printer output of REPOR FORM hanging up in the print queue forever after the report had been finished and then it printed immediately after we added the SEST PRINTER TO command after the REPORT FORM ... Need to verify with the print method of ? and @ ... Say syntax .
 

Part and Inventory Search

Sponsor

Back
Top