xHarbour Reference Documentation > Function Reference |
Searches a value in an array beginning with the last element.
RAscan( <aArray> , ; <xbSearch>, ; [<nStart>] , ; [<nCount>] , ; [<lExact>] , ; [<lASCII>] ) --> nElement
RAScan() returns the numeric ordinal position of the array element that contains the searched value. When no match is found, the return value is 0.
The array function RAscan() traverses the array <aArray> for the value specified with <xbSearch>. If <xbSearch> is not a code block, RAscan() 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.
Note: use function AScan() to search an array beginning with the first element.
See also: | AEval(), Asc(), Ascan(), ASort(), ATail(), Eval(), IN, SET EXACT |
Category: | Array functions , xHarbour extensions |
Source: | vm\arrayshb.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the difference between AScan() and RAscan(). PROCEDURE Main() LOCAL aArray := { "A", 1, Date(), 1, .F. } ? Ascan( aArray, 1 ) // result: 2 ? RAScan( aArray, 1 ) // result: 4 RETURN
http://www.xHarbour.com