Positron Compiler Documentation

On GoToL

Positron8 · Revision 4.0.6.5 · PDF page 310

On Index Variable GoToL Label1 {,...Labeln }

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.

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.

  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.

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.

See also : Branch, BranchL, On GoTo, On GoSub .

View original PDF page 310Open page in PDFOriginal PDF page 310