Equinox Online Help - Language Reference - A to Z
ArrayFind |
|
---|---|
Applies to | |
Syntax | ArrayFind ArrayExpression, SearchExpression [, SearchOrderExpression, ColumnExpression, IndexItem1, IndexItem2, IndexItem3, IndexItem4] |
Action | [Statement] Searches for an item within an array. |
Scope | Usable anywhere. |
Notes | This statement searches for the item SearchExpression, inside ArrayExpression. The ArrayFindNext statement uses the index parameters returned by a previous ArrayFind statement as the place to start searching from. SearchOrderExpression can take one of the following values:
ColumnExpression specifies the element in the rightmost dimension that is searched in multi-dimensional arrays. If omitted or zero, every element is searched. If a case insensitive search on a string array is required, add 4 to SearchOrderExpression. V6 further allows the option to return the place in a sorted array where the test item would be inserted, rather than zeroes in the IndexItem parameters. Add 8 to the SearchOrderExpression parameter. SysError is returned as 1 if the array does not contain the item, otherwise zero. If the item is not found, SysError is set to a nonzero value and zero is returned in the four final parameters if supplied. Otherwise, SysError is set to zero, and the index in each array dimension is returned in the four final parameters. Note that in order for ArrayFindNext to work, you must supply an argument to receive the array index for each significant dimension in the array. ArrayFindNext only works in unsorted arrays, and otherwise returns not found. This is useful in order to find out where to insert a new item in a sorted array. |
Category | Arrays |
See Also | ArrayFindNext, ArrayGetDimensions, ArraySearch, ArraySearchNext, ArraySetDimensions, ArraySort, ArrayNeg, ArrayNot, Vector, VectorSize |
Example | The following example finds all instances of "hello" in any case. The SearchOrderExpression has a value of 6, 2 for the search order + 4 so that the search is case insensitive: string s[], target The following example searches in the second column of the two dimensional array for 42: number values[100][2] The following example shows how to use the 2 new additions to SearchOrderExpression: procedure InsertIntoSortedArray int array[], int value, logical descendingint idx, nend procedure | InsertIntoSortedArray |