- Name:
- on goto
- Syntax:
-
ON offset GOTO address0,address1...addressN
Offset - is a variable/constant which specifies which Address# to use (0-N).
Addresses - are labels which specify where to go.
- Description:
-
Branch to address specified by offset (if in range).
This command allows a jump to different program positions depending on the value of the variable 'offset'. If offset is value 0, the program flow will jump to address0, if offset is value 1 program flow will jump to adddress1 etc. If offset is larger than the number of addresses the whole command is ignored and the program continues at the next line. This command is identical in operation to branch
Set LED according to variable value
The 'on goto' branch taken depends on the value of the b1 variable and as it increases a different LED will be set.
- Code Example:
-
reset1: let b1 = 0 low B.0 low B.1 low B.2 low B.3 main: inc b1 if b1 > 4 then reset1 on b1 goto btn0,btn1, btn2, btn3, btn4 btn0: high B.0 ; always skipped in this example goto main btn1: high B.1 goto main btn2: high B.2 goto main btn3: high B.3 goto main btn4: high B.4 goto main
Copy Code Submit an Example
Submit Your Own Code!
You must be logged in to submit code examples. Login now.