Daniel,
This seem to be a lot to print an ticket invoice. I do not understand any of what you are doing. I have many customers using starpos and I just install
star as a windows printer, port usb, set the security, give it a share name, drivers star drivers for the printer. Then I just use:
Code: Select all
Procedure Printsmall
*------------------------------------------------------------------------------*
Local i ,lSuccess, pl:= 0, Page := 1, PR := ALLTRIM(Controls->prn1) // prn1 = star share name or name
Parameter DI
DI:= .T. //normanly sent from preceding program
go top
if upper(di) = 'DIRECT'
SELECT PRINTER PR TO LSUCCESS ; //PREVIEW ;
ORIENTATION PRINTER_ORIENT_PORTRAIT ;
QUALITY PRINTER_RES_MEDIUM
else
SELECT PRINTER PR TO LSUCCESS PREVIEW;
ORIENTATION PRINTER_ORIENT_PORTRAIT ;
QUALITY PRINTER_RES_MEDIUM
endif
If lSuccess <> .T. //== .T.
MsgInfo('Print Not Available')
return
EndIf
// Measure Units Are Millimeters
START PRINTDOC
pl:=pl+5
START PRINTPAGE
pl:=pl+5
@ pl,27-(len(alltrim(mco))/2) print mco ; // COMPANY INFORMATION
FONT "Arial" ;
SIZE 8
@ pl+4,27-(len(alltrim(mcoaddress))/2) Print Mcoaddress SIZE 8
@ pl+8,27-(len(alltrim(mcomailing))/2) Print Mcomailing SIZE 8
@ pl+12,27-(len(alltrim(mcocity))/2) -(len(alltrim(mcoprovince))/2) ;
Print trim(mcocity)+ ' '+ mcoprovince SIZE 8
@ pl+16,27-(len(alltrim(mcopocode))/2) Print Mcopocode + ;
space(18)+mcophone SIZE 8
pl:=pl+24
@ pl+4,5 Print 'Sold To: ' + customer->name FONT "Arial" SIZE 7 // CUSTOMER INFORMATION
if upper(type) = 'REPRINT' // REPRINT POSTED INVOICE
@ pl+8,5 Print type + ':# ' + p_inv->inv FONT "Arial" SIZE 7 //'Invoice #: '+invoice->inv
@ pl+12,5 Print dtoc(p_inv->sal_dat) FONT "Arial" SIZE 7
@ pl+12,57 Print SUBSTR(TIME(),1,5) FONT "Arial" SIZE 7
@ pl+16,5 Print "Sales Per: " + p_inv->sal_per FONT "Arial" SIZE 7
if len(alltrim(customer->ssno)) > 0
@ pl+16, 52 print 'Pst#: '+customer->ssno FONT "Arial" SIZE 7
endif
@ pl+20,5 print 'Pd.by: '+p_inv->payment FONT "Arial" SIZE 7
@ pl+24,5 print substr(p_inv->po_num,1,48) FONT "Arial" SIZE 7
pl:=pl+24
else
@ pl+8,5 Print type + ':# ' + invoice->inv FONT "Arial" SIZE 7 // POST SALES INVOICE
@ pl+12,5 Print dtoc(date()) FONT "Arial" SIZE 7
@ pl+12,57 Print SUBSTR(TIME(),1,5) FONT "Arial" SIZE 7 //82
@ pl+16,5 Print "Sales Per: " + pcode FONT "Arial" SIZE 7
if len(alltrim(customer->ssno)) > 0
@ pl+16, 52 print 'Pst#: '+customer->ssno FONT "Arial" SIZE 7
endif
if upper(type) = 'INVOICE'
if mpay8 == ''
mpay8:=mpay1
endif
@ pl+20,5 print 'Pd.by: ' +p_inv->payment FONT "Arial" SIZE 7 //+mpay8
@ pl+24,5 print substr(invoice->po_num,1,48) FONT "Arial" SIZE 7
pl:=pl+24
else
@ pl+20,5 print substr(invoice->po_num,1,48) FONT "Arial" SIZE 7
pl:=pl+20
endif
endif
@ pl+4,2 print 'Item Description '+;
' Amount' FONT "Arial" SIZE 7
@ pl+8,1 Print Line TO pl+8,80 penwidth 0.1 //110
pl:=pl+6 //8
go top
do while ! eof()
if eof()
exit
endif
@ pl+4,1 print item FONT "Arial" SIZE 6 bold //10
@ pl+4,22 print desc FONT "Arial" SIZE 6 BOLD //45
@ pl+4,70 print val(str(qty*unit_price,10,2)) right FONT "Arial" SIZE 7 //110
pl:=pl+4
if pl >= controls->invlines*4
END PRINTPAGE
START PRINTPAGE
PL := -4
endif
skip
loop
enddo
@ pl+4,1 Print Line TO pl+4,80 penwidth 0.1
pl :=pl+2
@ pl+4,38 Print 'Sub-Total:' FONT "Arial" SIZE 7
@ pl+4,70 Print Form_Grid_IN2.TEXT_1.VALUE right FONT "Arial" SIZE 7
@ pl+8,2 Print 'Gst#: '+controls->gst SIZE 7
@ pl+8,40 Print 'Gst-Tax:' FONT "Arial" SIZE 7
@ pl+8,70 Print Form_Grid_IN2.TEXT_3.VALUE right FONT "Arial" SIZE 7
* @ pl+16,10 Print controls->comment1 FONT "Arial" SIZE 7
@ pl+12,40 Print 'Pst-Tax:' FONT "Arial" SIZE 7
@ pl+12,70 Print Form_Grid_IN2.TEXT_2.VALUE right FONT "Arial" SIZE 7
* @ pl+16,10 Print controls->comment2
@ pl+16,43 Print 'Total:' FONT "Arial" SIZE 7
if upper(type) = 'INVOICE'
@ pl+16,70 Print Ptotal right FONT "Arial" SIZE 7
else
@ pl+16,70 Print Form_Grid_IN2.TEXT_4.VALUE right FONT "Arial" SIZE 7
endif
*memo
pl := pl +24
if file('mem\tape.mem') // I HAVE A MEMORY FILE TO PRINT AT BOTTOM OF INVOICE
memfil=alltrim('mem\tape.mem') // SPECIALS COMING UP.. MERRY CHRISTMAS AND SO ON
mem_var = MEMOREAD(memfil)
PL1 = MLCOUNT(mem_var,60) //120
IF PL1 > 3 //10
PL1 = 3 //10
ENDIF
FOR PL2 = 1 TO PL1
PL3 = MEMOLINE(mem_var,60,PL2) //120
@ pl ,2 print PL3 FONT "Arial" SIZE 7
pl:=pl+4
NEXT
pl:=pl+4
endif
PL:=PL+20
IF CONTROLS->CUTTER = 'S'
@ PL,-5 PRINT CHR(27)+CHR(100)+CHR(01)
ENDIF
IF CONTROLS->CASHDRAWER = 'S'
@ PL,-5 PRINT CHR(7)
ENDIF
END PRINTPAGE
END PRINTDOC
return
i LIKE TO HAVE A CONTROLS CUMPANY FILE WITH 1 RECORD TO SET VALUES TO BE PICKED THROUGHOUT THE PROGRAM.
I do not know if this makes sense but may help someone.
Franco