|
gablea on 08/13/11 - 15:38:14
Hi all,
I have some need of someone wisdom. I have a FreeBASIC applciation that works perfectly. but I am trying to do a QuickBasic version and I am not having much luck. what I want to do is check the status of the cash drawer when the change screen is displayed. this is the code I have so far translated into QuickBasic DIM A AS STRING DIM B AS STRING DIM keyprs AS STRING DIM Aint AS INTEGER DIM t AS DOUBLE DIM errflag AS INTEGER DIM timeropen AS DOUBLE DIM PoSPrinter AS INTEGER PoSPrinter = FREEFILE ' Open The cash Drawer OPEN "Com3" FOR RANDOM AS #PoSPrinter DO A = INPUT$(LOC(PoSPrinter), 1)'clears data from serial buffer A = "" PRINT #PoSPrinter, Chr(29); Chr(114); CHR$(2); ' get the status from the printer errflag = 0 t = TIMER IF CashDrwOpen <> 9999 THEN timeropen = TIMER WHILE LOC(PoSPrinter) = 0 IF TIMER - t > TimeOutLimit THEN CashDrwOpen = -1 EXIT DO END IF SLEEP 1 WEND A = INPUT$(PoSPrinter, 1) Aint = VAL("&H" + Hex(ASC(A), 2)) IF (Aint AND 1) = 0 THEN ' Cash Drawer open A = "" CashDrwOpen = 9999 IF CashDrawerAudioAlarm = "Yes" THEN IF TIMER - timeropen > 30 THEN PRINT "PLEASE CLOSE CASH DRAWER" END IF END IF END IF IF (Aint AND 1) = 1 THEN ' Cash Drawer closed EXIT DO END IF SLEEP 100 LOOP IF CashDrwOpen = -1 THEN 'comm timeout LOCATE 1, 15 PRINT "No response from cash drawer" ELSE PRINT "CASH DRAWER CLOSED :)" END IF CLOSE #PoSPrinter END This is some code I have found online for QBasic do A1 = INP(&H38E) AND (&H40) 'Com3 IF A1 > 0 THEN PRINT "Drawer is open" ELSE PRINT "Drawer is CLOSED" Exit do CLOSED Loop END the Qbasic one does not work it keeps saying drawer is closed EVEN when It is open ALL i need the system to do is when the drawer is closed to call the reset fucntion (at the moment this is done when the user presses enter)
Todd on 09/07/11 - 14:23:11
If QB is saying the drawer is closed despite when it's open, it's more than likely an issue with your communications port to the cash register.
One thing is that I noticed the INP(&H38E) call which seems like the link to talk to the register. Why not make a program that loops until you press ESC and prints the result of INP(&H38E) and see if it changes when you open and close the cash register. If it changes then that's a sign that there might be an issue with one of the bits (as handled by the AND(&H40)).
gablea on 09/12/11 - 07:22:55
@Todd,
ok I shall look into that can I print the contect of the INP(&H38E) Directly or do I need to store it first in a verabile?
Todd on 09/12/11 - 15:12:28
Reply to this message
It's probably going to be an integer so I would see about trying to just print it like this:
PRINT STR$(INP(&H38E)) |
|