Cicode Programming Reference > Cicode Function Categories > Table (Array) Functions Introduction > TableLookup

TableLookup

Searches for a value in a table, and returns the position (offset) of the value in the table. Be aware that the first item in a table is offset 0 (zero), the next item is offset 1, etc.

Note: This function only supports arrays declared in Cicode and not variable tag arrays.

Syntax

TableLookup(Table, Size, Value)

Table:

The table to search. The table needs to be an array of real numbers.

Size:

The maximum number of items in the table.

Value:

The value to locate.

Return Value

The offset to the table value, or -1 if the value does not exist.

Related Functions

TableMath

Example

REAL Levels[5]=10,15,50,100,200;
Variable=TableLookup(Levels,5,50);
! Sets Variable to 2.
Variable=TableLookup(Levels,5,45);
! Sets Variable to -1.

See Also

Table (Array) Functions