Quote Originally Posted by andybarrett1 View Post
Now Then Steve...

Did it a lazy way.... But hey it works now !!!

Code:
Main:
 
    SERIN2 portb.1,84, [WAIT($02), STR buf\10]	' Read RFID

    IF ("C" = buf(9)) and ("9" = buf(8))THEN loc1
    IF ("C" = buf(9)) and ("2" = buf(8))THEN loc2
    IF ("A" = buf(9)) and ("C" = buf(8))THEN loc3
    IF ("3" = buf(9)) and ("C" = buf(8))THEN loc4

    goto main
I know it rough... But I can see how it works !!!
Are you sure you can see how it works?

IF ("C" = buf(9)) and ("9" = buf(8))THEN loc1

Looks like

IF ("C" = buf(9)) THEN
IF ("9" = buf(8)) THEN
loc1
ENDIF
ENDIF

which is the positive and obvious way of looking at it but there is another way.


IF ("C" != buf(9)) THEN nextTag
IF ("9" != buf(8)) THEN nextTag
loc1
nextTag:

Call this the negative vision. This is looking for a failure and is more efficient because if the first character fails then no others are tested.

But it works more like this

compFlag var bit
compFlag=1

IF ("C" != buf(9)) THEN compFlag=0
IF ("9" != buf(8)) THEN compFlag=0
IF compFlag=1 THEN loc1


You have almost spotted another reason your code did not work there is a clue in this line

IF ("C" = buf(9)) and ("9" = buf(8))THEN loc1

which indicates to me that you have worked it out.

I will leave that one as more food for thought.