Action
Branch to one of several specified labels, depending on the value of a variable.
Syntax
ON var [GOTO] [GOSUB] label1 [, label2 ]
Remarks
Var |
The numeric variable to test. This can also be a SFR such as P1. |
label1, label2 |
The labels to jump to depending on the value of var. |
Note that the value is zero based. So when var = 0, the first specified label is jumped/branched.
See Also
Example
Dim X As Byte
X = 2 'assign a variable interrupt
On X Gosub Lbl1 , Lbl2 , Lbl3 'jump to label lbl3
X = 0
On X Goto Lbl1 , Lbl2 , Lbl3
End
Lbl3:
Print "lbl3"
Return
Lbl1:
nop
Lbl2:
nop
'nop is an ASM statement that does nothing