Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Send ESCape to POS PRINTER
Message
 
To
24/10/2006 21:23:10
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01164066
Message ID:
01164261
Views:
19
Hi Tore

We adopt the approach of creating a file containing the ESC sequences etc, and then copy that to the printer. Here are some samples - works very well for us...
* ----------------------------------------------------
PROCEDURE OpenDrawer
* open receipt drawer

if !mlOpenDrawer
	return
endif

do case
case station.printer=2			&& dumb as, laser etc - no drawer
	return
case station.printer=3			&& Epson TM-U21OD Receipt Printer
	do PrintLine with chr(27)+'p0((', .t.
otherwise						&& Star SP210 - may have drawer
	do PrintLine with chr(28), .t.
endcase

return




* ----------------------------------------------------
PROCEDURE PrintLine
* print receipt line or control code to appropriate device
PARAMETERS pcString, plControl
PRIVATE mcWriteBuff, mcString, mlControl, mnWritten, mnHandle
mlControl=iif(type('plControl')='L',plControl,.F.)

* fix mcString for printer type
if !mlControl
	do case
	case station.printer=2			&& dumb as, laser etc with CRLF
		mcString=pcString+chr(13)+chr(10)
	otherwise						&& Star SP210 - LF only
		mcString=pcString+chr(10)
	endcase
else
	mcString=pcString
endif

do case
case station.port=4
	* no print, no nothing...
otherwise
	erase (mcRecFile)
	mnHandle=fcreate(mcRecFile)
	=fwrite(mnHandle, mcString)
	=fclose(mnHandle)
	* this MAY be necessary to let caching etc settle
	=inkey(.1)

	do case
	case station.port=1		&& LPT1
		copy file(mcRecFile) to lpt1
	case station.port=2		&& LPT2
		copy file(mcRecFile) to lpt2
	case station.port=3		&& LPT3
		copy file(mcRecFile) to lpt3
	otherwise
		* com ports...not implemented in SO32 (yet)
		* but can easily be redirected to an LPT port - yes, it works!
	endcase

	erase (mcRecFile)
endcase

return



* ------------------------------------------
PROCEDURE ResetPrinter
* some printers need special reset (lasers etc)

do case
case station.printer=2		&& generic printer
	* Generic printer, send formfeed
	=PrintLine(chr(12), .T.)
otherwise
	* do nothing
endcase

return
HTH
Previous
Reply
Map
View

Click here to load this message in the networking platform