LookUp
Description: |
Looks up a value in an array and returns the index of the element containing that value. This function replaces the deprecated TextSearchList and SearchForListItem system modules. |
Returns: | Numeric |
Usage: | Script or Steady State |
Function Groups: | Array |
Related to: | AMax | AMin | ArrayDimensions | ArraySize | ArrayStart | AValid | Sort | Sum | TextSearch |
Format: | Lookup(ArrayElem, N, Match [, CaseInsensitive]) |
Parameters: |
ArrayElem |
Required. Any array element giving the starting index for the array operation. The index for the array may be any numeric expression. If processing a multidimensional array, the usual rules apply to decide which dimension should be examined |
N |
Required. Any numeric expression giving the number of array elements to compute. If N extends past the upper bound of the lowest array dimension, this computation will "wrap-around" and resume at element 0, until N elements have been processed. |
Match |
Required. Any value of any type to look for in the array. In the case of text, the search is case sensitive. If this value is invalid, the return value will also be invalid. |
CaseInsensitive |
An optional parameter that is any logical expression. If true (non-0) and the array contains text strings, the comparison will not be case sensitive. If false (0), the comparison will be case sensitive for text strings. The default is false. |
Comments: |
It is acceptable for the array to contain invalid values - these will be skipped over in the search for Match. Note that TextSearch should be used for large arrays due to its considerably faster search algorithm. |
Example:
index = Lookup(labels[0], ArraySize(labels, 0), "off", 1);
This searches the array labels for a string of any case that matches the string "off". If a match is found, its value is assigned to index.