Positron Compiler Documentation

LookUp

Source: Positron8 Compiler User Manual, PDF page 406

Syntax

Variable = LookUp Index, [ Constant {, Constant…etc } ]

Overview

Look up the value specified by the index and store it in variable. If the index exceeds the highest index value of the items in the list, then variable remains unchanged.

Parameters

Variable may be a constant, variable, or expression. This is where the retrieved value will be stored. Index may be a constant of variable. This is the item number of the value to be retrieved from the list. Constant(s) may be any 8-bit value (0-255). A maximum of 255 values may be placed between the square brackets, 256 if using an 18F device.

Example

' Create an animation of a spinning line.
  Device = 18F26K40
                                  ' Select the device to compile for
  Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
  Dim Index as Byte
  Dim Frame as Byte
  Cls
                             ' Clear the LCD
  Do
     For Index = 0 to 3
                             ' Create a loop of 4
       Frame = LookUp Index, [ "|\-/" ] ' Table of animation characters
       Print At 1, 1, Frame ' Display the character
       DelayMs 200
                             ' So we can see the animation
     Next
                             ' Close the loop
  Loop
                             ' Repeat forever

Notes

index starts at value 0. For example, in the LookUp command below. If the first value (10) is required, then index will be loaded with 0, and 1 for the second value (20) etc.

  Var1 = LookUp Index, [10, 20, 30]

See also : Cdata, Cread, Cread8, Cread16, Cread24, Cread32, Dim As Code, Edata,

Eread, Ldata, LookDown, LookDownL, LookUpL, Lread, Lread8, Lread16,

Lread24, Lread32.