hbmk2 -doc ascan
AUTHOR
------
Copyright 1999 Luiz Rafael Culik <
culik@sl.conex.net>
TEMPLATE
--------
Function
NAME
----
AScan()
CATEGORY
--------
API
SUBCATEGORY
-----------
Array
ONELINER
--------
Scan array elements for a specified condition
SYNTAX
------
AScan( <aArray>, <xSearch>, [<nStart>], [<nCount>] ) --> nStoppedAt
ARGUMENTS
---------
<aArray> Array to be scanned.
<xSearch> Expression to search for in <aTarget>
<nStart> Beginning subscript position at which to start the search.
<nCount> Number of elements to scan with <aTarget>.
RETURNS
-------
<nStoppedAt> A numeric value of subscript position where <xSearch>
was found, or 0 if <xSearch> is not found.
DESCRIPTION
-----------
This function scan the content of array named <aArray> for the
value of <xSearch>. The return value is the position in the array
<aArray> in which <xSearch> was found. If it was not found, the
return value will be 0.
<nStart> is the position from which to start scanning. The default
is 1. (1st element)
<nCount>, if specified, is the number of array elements to be scanned.
The default is all elements in the array <aArray>.
If <xSearch> is a code block, the operation of the function is
slightly different. Each array subscript pointer reference is
passed to the code block to be evaluated. The scanning routine
will continue until the value obtained from the code block is a
logical true (.T.) or until the end of the array has been reached.
EXAMPLES
--------
#include "directry.ch"
LOCAL aDir := hb_vfDirectory( "*.prg" )
? AScan( aDir,,, ;
{| aFile, nPos | HB_SYMBOL_UNUSED( nPos ), aFile[ F_NAME ] == "test.prg" } )
SEEALSO
-------
AEval()
AUTHOR
------
2016 Pete D. <
pete_westg@yahoo.gr>
TEMPLATE
--------
Function
NAME
----
hb_AScan()
CATEGORY
--------
API
SUBCATEGORY
-----------
Array
ONELINER
--------
Scan array elements for a specified condition
SYNTAX
------
hb_AScan( <aArray>, <xSearch>, [<nStart>], [<nCount>], [<lExact>] ) --> nPosition
ARGUMENTS
---------
<aArray> Array to be scanned.
<xSearch> Expression to search for in <aArray>
<nStart> Beginning subscript position at which to start the search.
Default value: 1
<nCount> Number of elements to be scanned within <aArray>.
Default value: All elements.
<lExact> Boolean flag specifying if an "Exact" search will be
performed or not. Default value: .F.
RETURNS
-------
<nPosition> A numeric value > 0 indicating the array position
where <xSearch> was found, or 0 if nothing found.
DESCRIPTION
-----------
The function scans (left to right) for <xSearch> into <aArray>
and returns <nPosition> of <aArray> in which <xSearch>
was found or 0 (zero) if nothing found.
If <lExact> is .T., then an exact search will be performed.
When <xSearch> is a code block, the operation of the function
is slightly different. See AScan() for details.
EXAMPLES
--------
LOCAL a := { "there", "here" }
Set( _SET_EXACT, .F. )
? AScan( a, "he" ) // --> 2
? hb_AScan( a, "he",,, .F. ) // --> 2
? hb_AScan( a, "he",,, .T. ) // --> 0
SEEALSO
-------
AScan(), AEval()