ON Value
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.

Example


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:

Lbl2: