On GoToL
Syntax
On Index Variable GoToL Label1 {,...Labeln }
Overview
Cause the program to jump to different locations based on a variable index. On a PICmicro™ device with more than one page of memory, or 18F devices. Exactly the same functionality as
BranchL.
Parameters
Index Variable is a constant, variable, or expression, that specifies the label to jump to. Label1...Labeln are valid labels that specify where to branch to. A maximum of 127 labels may be placed after the GoToL, 256 if using an 18F device.
Example
Device = 16F1829
' Use a larger PICmicro device
Declare Xtal = 20
' Tell the compiler the device is operating at 20MHz
Declare Hserial_Baud = 9600 ' Choose the Baud rate for HRsoutLn
Dim Index as Byte
Index = 2
' Assign Index a value of 2
Start:
' Jump to label 2 (Label_2) because Index = 2
On Index GoToL Label_0, Label_1, Label_2
Label_0:
Index = 2
' Index now equals 2
HRsoutLn "Label 0"
' Display the Label name
GoTo Start
' Jump back to Start
Label_1:
Index = 0
' Index now equals 0
HRsoutLn "Label 1"
' Display the Label name
GoTo Start
' Jump back to Start
Label_2:
Index = 1
' Index now equals 1
HRsoutLn "Label 2"
' Display the Label name
GoTo Start
' Jump back to Start
The above example we first assign the index variable a value of 2, then we define our labels. Since the first position is considered 0 and the variable Index equals 2 the On GoToL command will cause the program to jump to the third label in the list, which is Label_2.
Notes
The On GoToL command is mainly for use with PICmicro™ devices that have more than one page of memory (greater than 2048). It may also be used on any PICmicro™ device, but does produce code that is larger than On GoTo.