Description: This function returns the array index of the first occurrence of the given text key in an alphabetically ordered array.
Returns: Numeric
Usage: Script or Steady State
Format: TextSearch(ArrayElem, N, Text, Case)
Parameters: ArrayElem { Array element } { required } { no default: }
Any array element giving the starting index for the array operation. The index for the array may be any numeric expression. Unless specified, the lowest dimension of a multidimensional array is used. It does not allow searches on elements within multidimensional arrays beyond the lowest dimension.
N { numeric } { required } { no default: }
Any numeric expression for the number of array elements to search.
Text { text } { required } { no default: }
Any text expression to search for.
Case { Boolean } { required } { no default: }
Any logical expression. If true, the search is case-sensitive; otherwise, the search is case-insensitive.
Comments: If the key is not found in the array, the function returns invalid. Notice that the array (or the elements being searched in the array) must be in ascending alphabetical order for this statement to return a valid value.
Example:
index = TextSearch(dataArray[0] { Start of search in array },
ArraySize(dataArray, 0)
{ Search all elements },
"green" { Text string to search for },
0 { Case insensitive search });
Given that dataArray is an array of text strings of various color names, index will be set to the subscript of the array element whose entry is "green".
See Also: