ReadTable

About ReadTable

The ReadTable command is used to read information from lookup tables. TableName is the name of the table that is to be read, Item is the line of the table to read, and Output is the variable to write the retrieved value in to.

Syntax:

    ReadTable TableName, Item, Output

Command Availability:

Available on all microcontrollers.

Explanation:

Item is 1 for the first line of the table, 2 for the second, and so on. Item 0 gives the size of the table. Care must be taken to ensure that the program is not told to read beyond the end of the table, or strange effects will be observed.

The type of Output should match the type of data stored in the table. For example, if the table contains Word values then Output should be a Word variable. If the type does not match, Great Cow BASIC will attempt to convert the value.

Example:

    'Chip Settings
    #chip 16F88, 20

    'Hardware Settings
    #define LED PORTB.0
    Dir LED Out

    'Main Routine
    ReadTable TimesTwelve, 4, Temp
    Set LED Off
    If Temp = 48 Then Set LED On

    'Lookup table named "TimesTwelve"
    Table TimesTwelve
    12
    24
    36
    48
    60
    72
    84
    96
    108
    120
    132
    144
    End Table

For more help, see Lookup Tables