Function AScan() Foundation
Searches an array for a specified value.
AScan( <aArray>, <bxSeekExpr>, [<nStart>], [<nCount>]) --> nElement
The return value of AScan() is a positive integer designating the first element where the value of <bxSeekExpr> is found. When <bxSeekExpr> is a code block, AScan() returns the position of the first element where the code block returns the value .T. (true). If the search is unsuccessful, AScan() returns zero.
The array function AScan() is used to search an array for a value. If <bxSeekExpr> is not a code block, the value of <bxSeekExpr> is compared with the value of each array element. The search begins with the element <nStart> and compares <nCount> array elements. As soon as a match is found, AScan() terminates the search, returning the position of this array element as a numeric value. AScan() uses the simple equals operator (=) for the comparison. Because of this, the search of character strings is dependent on the settings SET EXACT, SET LEXICALand SET COLLATION.
The array can have multiple dimensions. AScan() searches a value in all dimensions of a multi-dimensional array. The return value, however, points always to an array element of the first dimension.
When <bxSeekExpr> is a code block, the search occurs only in the first array dimension. AScan() evaluates the code block passing it the contents of each array element. The code block must perform a comparison and return a logical value. As soon as the code block returns .T. (true), AScan() terminates and returns the position of this element. The code block is necessary when a complex search condition must be used.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.