Look up tables allow you to store constant data in a table and access it. The table can have any number of rows and columns and the data can be of any constant type.
Access to the table is via the list_lookup command this takes 4 arguments, the variable to return the table value in, the second argument is the name of the lookup table and the final argument gives the row and field of the required item. So the following code will set Data to the value in column 3, field 2 of the table LookUpTable1
lookup_get Data LookUpTable 3 2
The lookup_size command can be used to get the size of a lookup table. To get the number of fields and rows in the table LookUpTable use.
lookup_size NumFields NumRows LookUpTable
The example below defines a table and then displays the data within the table on the screen.
//---------------------------------------
// File: LookUp.e
//---------------------------------------
//---------------------------------------
// Look Up: Table1
//---------------------------------------
lookup Table1
1 "Line1" 'a' true 4.56
2 "Line2" 'b' false 5.56
3 "Line3" 'c' true 6.56
4 "Line4" 'd' false 7.56
_lookup
//---------------------------------------
// Block: go
//---------------------------------------
block Go
lookup_size TableFields TableRows Table1
Row = 0
while Row < TableRows
Col = 0
while Col < TableFields
lookup_get Data Table1 Col Row
out Data " "
var_del Data
++ Col
_while
new_line
++ Row
_while
_block
Note the use of the var_del command this deletes the variable so that it gets recreated to the correct type when lookup_get gets called the next time. If this wasn't done then the Data variable would always be of type int as it would be initialized on the call to read row 0, column 0 which is an integer value.