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

Receipt Printing Problem 1

Status
Not open for further replies.

tondi

Technical User
Nov 29, 2001
115
US
My app has migrated over the years from Foxbase to VFP8. We still use a lot of the old code so I still have a challenge with POS features on Win Computers. I would appreciate any suggestions or solutions.

Example of code used after adding generic printer named POS. The routine works only if I remark out the "set printer to name" line in which case it goes to the default printer, which I am trying to avoid. I would like to
send to a com port or usb port when necessary as clients all have different scenarios to deal with.

********************************
*Select the POS printer / drawer
SET DEVICE TO print
SET PRINTER TO NAME "POS"
??? CHR(7) && Send Bell for Cash Drawer
@PROW(),5 say "12345" && Receipt Details
SET DEVICE TO screen
* Reselect Default Printer
SET PRINTER TO DEFAULT

* Continue
********************************
 

Tondi,

I think your general approach is correct.

When you install the generic printer driver, you need to tell it which port the printer is connected to. You do that in the printer's property sheet in control panel.

Unfortunately, I cannot tell you how to do that programmatically.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks Mike,
When I add the Generic printer I do assign it to the port but it still doesn't print unless I remark out the printer name line for some reason, even if assigned to the default LPT1 port. I suspect the issue is the use of the 'set printer to name.'
Tony
 
I laboured long and hard with a Star receipt printer, fighting with the same problems you are encountering.
As we only use 2 receipt layouts, I found the best solution was to create the receipt in code and save it to a .txt file.
Printing the file is simply a case of copying the file to LPT1:
Code:
! COPY RECEIPT1.TXT LPT1

Keith
 
Thanks Keith,
We do create the receipt in code and send details to the receipt printer. Your solution may work when using LPT1 but I suspect may not work with COM and USB ports on Windows Systems.

I remember Rick mentioning he does a lot of receipts using Rawprint. I'm hoping he weighs in and possibly offer an example or snippet of how he does so.

Tony
 
Thanks Rick,
I have downloaded the Rawprint files.
I was hoping you would share an example
of how to best use the program.
Thanks, I appreciate your inpu.
Tony
 
Tony,
We print bitmap files to a receipt printer. Epson provides a program to convert the bitmap file to a string of binary characters including escape codes. We get this file in a string and pass it to this routine.
Code:
*Procedure PrtRcptBMP
LPARAMETER zcEscPosCodes

LOCAL lcPrinter
lcPrinter = UPPER(SET("PRINTER", 2))

IF EMPTY(zcEscPosCodes) OR oData.gcrcpttype != "E" OR ;
		! ("EPSON" $ lcPrinter OR "RECEIPT" $ lcPrinter OR "T8" $ lcPrinter)
	** No codes or No Epson attached or not a receipt printer...
	RETURN
ENDIF

LOCAL lcSavePrinter
lcSavePrinter = SET("PRINTER", 3)
SET PRINTER TO NAME (lcPrinter)


LOCAL oPrnDev
SET CLASSLIB TO RawPrint ADDITIVE
oPrnDev = CREATEOBJECT("PrintDev")
oPrnDev.cPrinterName = lcPrinter
oPrnDev.cDocName = "Receipt Logo"
IF oPrnDev.oOPen()
	** Send the codes and reset the line spacing to 1/6th inch...
	oPrnDev.oPrintMem(zcEscPosCodes + CHR(27) + "2")
	oPrnDev.oClose()
ELSE
	* Error opening device; fall thru for now
ENDIF
RELEASE oPrnDev
RELEASE CLASSLIB RawPrint
SET PRINTER TO NAME (lcSavePrinter)
*EOP: PrtRcptBMP
Rick
 
Thanks Rick,

I need to use with different printers but I'm sure my programmer will find your code very helpful.

You have another STAR!

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top