PARAMETERS lIsTest
IF PARAMETERS() = 1
lIsTest = .T.
nNextNum = 999999
ELSE
lIsTest = .F.
ENDIF
*... This configuration is compiled from running the
*... "=CallFn(getcomm, 0, @cOldState)" function below.
STORE ;
CHR(0) + ;
CHR(128) + ;
CHR(37) + ;
CHR(7) + ;
CHR(2) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(1) + ;
CHR(0) + ;
CHR(17) + ;
CHR(19) + ;
CHR(10) + ;
CHR(0) + ;
CHR(10) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) + ;
CHR(0) ;
TO coldstate, cnewstate
opencomm = RegFn("OpenComm", "CII", "I")
writecomm = RegFn("WriteComm", "ICI", "I")
closecomm = RegFn("CloseComm", "I", "I")
getcomm = RegFn("GetCommState", "I@C", "I")
setcomm = RegFn("SetCommState", "I@C", "I")
*... open the comm port here
STORE 'COM' + ALLTRIM(STR(rcptport)) + ":" TO crcptport
out_com = callfn(opencomm, crcptport, 100, 100)
IF out_com = -1
DO caution WITH "*** CONFIGURATION ERROR ***", ;
"Unable to open communications port to print receipt!"
RETURN
ENDIF
*... get comm parameters just for comparison
=callfn(getcomm, 0, @cOldState)
*... set required comm parameters - 9600,7,E,1 according to above
=callfn(setcomm, 0, @cNewState)
WAIT WINDOW "Printing receipt # " + ALLTRIM(STR(nNextNum)) + "......" NOWAIT
*... header
=serialout(PADC(ALLTRIM(companyname), 40, ' '))
=serialout(PADC(ALLTRIM(m.cust_name), 40, ' '))
*... blank lines
FOR nline = 1 TO 5
=serialout('')
NEXT
*... If we're just calling this routine from the config screen
IF lIsTest
STORE 0 TO m.dollar_value &&... just so there's no error
*... print test stuff
=serialout('Date_________: ' + DTOC(DATE()))
=serialout('Time_________: ' + TIME())
=serialout('Cashier______: ' + m.s_username)
=serialout('Member Name__: Test Member')
=serialout('Member Number: 12345678')
=serialout('Description__: Test Print RDM')
=serialout('Points Ded.__: (0000.00)')
=serialout('Dollar Value_: $0000.00')
=serialout('Receipt #:___: 999999')
ELSE
*... print real stuff
=serialout('Date_________: ' + cPCDate)
=serialout('Time_________: ' + cPCTime)
=serialout('Cashier______: ' + m.s_username)
=serialout('Member Name__: ' + ALLTRIM(m.ar_rpt_name ))
=serialout('Member Number: ' + ALLTRIM(m.a_cif_nbr))
=serialout('Description__: ' + ALLTRIM(m.ar_desc)), 40)
=serialout('Points Ded.__: (' + ALLTRIM(STR(m.pnt_value))+ ')')
=serialout('Dollar Value_: $' + ALLTRIM(STR(m.dollar_value)) + '.00')
=serialout('Receipt #:___: ' + ALLTRIM(STR(nNextNum)))
ENDIF
*... blank lines
FOR nline = 1 TO 5
=serialout('')
NEXT
*... Customer signature line
=serialout('X' + REPLICATE('_', 38))
=serialout(' Customer Signature')
=serialout('')
=serialout('')
*... Club signature line
=serialout('X' + REPLICATE('_', 38))
=serialout(' Club Signature')
=serialout('')
=serialout('')
*... Cashier signature line
=serialout('X' + REPLICATE('_', 38))
=serialout(' Cashier Signature')
=serialout('')
=serialout('')
IF lIsTest .OR. m.dollar_value > 0 &&... they may change their mind for mgr sig amount
*... Manager signature line
=serialout('X' + REPLICATE('_', 38))
=serialout(' Manager Signature')
=serialout('')
=serialout('')
ENDIF
FOR nline = 1 TO 10 &&... blank lines
=serialout('')
NEXT
*... cut paper
=serialout(CHR(27) + 'i')
*... blank lines
FOR nline = 1 TO 3
=serialout('')
NEXT
*... close port for now
=callfn(closecomm, out_com)
WAIT CLEAR
RETURN
*...................... output workhorse ............................*
FUNCTION serialout
PARAMETERS coutstr
coutstr = LEFT(coutstr, 40) + CHR(13) + CHR(10)
=callfn(writecomm, out_com, coutstr, LEN(coutstr))
=INKEY(.1, 'HM')
RETURN
*:EOF ...rdmrcpt