Help Simplify If-Then Code
Humanoido
Posts: 5,770
' {$STAMP BS1} ' {$PBASIC 1.0} SYMBOL id = B0 SYMBOL c = B1 B0=96 Loop: IF B0 = 0 THEN c1 IF B0 > 11 AND B0 < 23 THEN c2 ' 017 IF B0 > 22 AND B0 < 35 THEN c3 ' 028 IF B0 > 34 AND B0 < 45 THEN c4 ' 040 IF B0 > 44 AND B0 < 55 THEN c5 ' 049 IF B0 > 64 AND B0 < 76 THEN c6 ' 070 IF B0 > 83 AND B0 < 95 THEN c7 ' 089 IF B0 > 105 AND B0 < 114 THEN c8 ' 111 IF B0 > 113 AND B0 < 122 THEN c9 ' 116 DEBUG "out of range error",CR:END c1:c=1:DEBUG c:GOTO Loop c2:c=2:DEBUG c:GOTO Loop c3:c=3:DEBUG c:GOTO Loop c4:c=4:DEBUG c:GOTO Loop c5:c=5:DEBUG c:GOTO Loop c6:c=6:DEBUG c:GOTO Loop c7:c=7:DEBUG c:GOTO Loop c8:c=8:DEBUG c:GOTO Loop c9:c=9:DEBUG c:GOTO Loop
Comments
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL id = B0
SYMBOL c = B1
SYMBOL v = B2
EEPROM (12,23,35,45,65,84,106,114,123)
id =96
c = 0
Loop:
READ c,v
c = c + 1
IF c = 10 THEN Error
IF id >= v THEN Loop
DEBUG c
STOP
Error:
DEBUG "Out of range error",CR
END
·