Tim,
From xharbour Language Reference Guide:
The array function AScan() traverses the array <aArray> for the value specified with <xbSearch>. If <xbSearch> is not a code block, AScan() compares the values of each array element for being equal with the searched value. If this comparison yields .T. (true), the function stops searching and returns the numeric position of the array element containing the searched value.
If a code block is passed for <xbSearch>, it is evaluated and receives as parameter the value of the current array element. The code block must contain a comparison rule that yields a logical value. AScan() considers the value as being found when the codeblock returns .T. (true). Otherwise the function proceeds with the next array element.
- Code: Select all Expand view
The example demonstrates simple and complex searching in arrays.
PROCEDURE Main()
LOCAL aArray := { "A", 1, Date(), NIL, .F. }
// one dimensional array
? AScan( aArray, 1 ) // result: 2
? AScan( aArray, .F. ) // result: 5
? AScan( aArray, {|x| Valtype(x)=="D" } )
// result: 3
// two dimensional array
aArray := Directory( "*.prg" )
? AScan( aArray, {|a| Upper(a[1]) == "TEST.PRG" } )
// result: 28
RETURN
Maybe by using the codeblock you can find a solution.