Thread: FoxPro Some General Questions/How to control programmatically the cash drawer and printer

How to control programmatically the cash drawer and printer
http://www.tek-tips.com/viewthread.cfm?qid=497610
http://www.tek-tips.com/viewthread.cfm?qid=764504
http://www.tek-tips.com/viewthread.cfm?qid=620012
http://www.tek-tips.com/viewthread.cfm?qid=501995
http://www.tek-tips.com/viewthread.cfm?qid=478026

some useful code :

cString = "UUUUU" && set to the string your printer needs eg. CGR(27)+chr(122)+CHR(0)+CHR(187)
cPort ="COM1:"
#Define ForReading 1
#Define ForWriting 2
oWshFile = CREATEOBJECT("Scripting.FileSystemObject")
If TYPE("oWshFile") #"O"
Return .F.
Endif
oCom = oWshFile.OpenTextFile(cport, ForWriting, .T.)
oCom.Write(cString)
oCom.Close
Release oCom
Release oWshFile
Return



Cash drawer connected to parallel receipt printer..


   Set device to print
   Set print to "LPT1"&&Works with XP
   @prow()  ,00 Say Chr(27)+"@"     &&  Initialize printer
   @prow()  ,pcol() Say Chr(28)  && Drawer Kick
   @prow()  ,pcol() Say Chr(7)   && Drawer Kick
   @prow()  ,pcol() Say Chr(7)   && Drawer Kick
   Set print to
   Set Device to Screen



For Epson printer - open Cash Drawer

set printer off
??? chr(27)+chr(112)+chr(48)+chr(50)+chr(53)
set printer TO



Windows printing strips out certain characters.
Here is a simple - fill a text file with the characters needed in this case on an Epson TMT88 printer to fire the till.

=StrToFile(CHR(27)+CHR(112)+CHR(0)+CHR(94)+CHR(121),"Till1.txt")

Then issue the command:

RUN TYPE TILL1.TXT>LPT1

This uses a redirection DOS command to output the contents of the text file to the printer (in this case LPT1)



made the printer as Generic/Text printer.
and send the prg code for printing but never printing right way but just print code itself.

For example

??chr(27)+'!'+chr(48) &&double-width+height

suppose to start to print double width and height, but just print chr(27)+'!'+chr(48).

If you have any solutin please help me.

These are the sample code if it helps your understanding.

*****************************************************
function header5(mlname,mreceiptno,mcustno,mfname,jobdisc)
*****************************************************
local cAdr2:=icity+", "+ist+" "+izip
local maddress:=iaddress

set console off
set device to print
set print on

&& ??chr(27)+'!'+chr(32) &&double-width

??chr(27)+'!'+chr(48) &&double-width+height
??space(7)+mreceiptno
??"-"+jobdisc

?
?
?? space(br_center(icompany, 20)) + icompany
??chr(27)+'!'+chr(0) &&double-width cancel

?
@prow(),br_center(maddress, 40) say maddress
?
@prow(),br_center(cAdr2, 40) say cAdr2
?
@prow(),br_center(iphone, 40) say iphone
?replicate('=',40)
?
??chr(27)+'!'+chr(16) &&double-height
??" Ticket No: "
??chr(27)+'!'+chr(48) &&double-width+height
?? mreceiptno
??"-"+jobdisc
??chr(27)+'!'+chr(0) && double-width+height end
?

if minvtype="T"
??chr(27)+"\"+chr(50)+chr(0)
??chr(29)+"w"+chr(2)
??chr(29)+"h"+chr(60)
??chr(29)+"k"+chr(4)+mreceiptno+chr(0) && barcode printing
?
endif

mpname=trim(mlname)+iif(len(trim(mfname))>0,","+subs(mfname,1,1)," ")
??chr(27)+'!'+chr(16) && double-width+height end
?? " Name: "
??chr(27)+'!'+chr(48) && double-width+height
??substr(mpname,1,18)
?
?
??chr(27)+'!'+chr(16) && double-width+height end
?? " Cust No: "
??chr(27)+'!'+chr(48) && double-width+height
??mcustno
??chr(27)+'!'+chr(0) && double-width+height end

?replicate('=',40)
?

set print off
set device to screen

return NIL && header5()