Function AEval() Foundation
Executes a code block for each array element.
AEval( <aArray>, <bBlock>, ;
[<nStart>], [<nCount>], [<lAssign>] ) --> aArray
The return value of AEval() is a reference to <aArray>.
The array function AEval() allows operations to be performed on the contents of array elements. The operations are programmed in a code block which is executed <nCount> times beginning with array element <nStart>. The contents of the current array element are passed to the code block as the first argument and the element index is passed as the second argument. After each execution, the index is incremented and the code block is evaluated with the next array element.
The contents of the array elements are not relevant to AEval(), since the function merely passes the contents of each element on to the code block. However, the code block must assure that only correct data types are processed.
// In the example various uses of AEval() are shown.
#include "Directry.ch"
PROCEDURE Main
LOCAL aArray[5]
// fill array elements with
// consecutive numbers
AEval( aArray, {|x,i| aArray[i] := i } )
// aArray is {1,2,3,4,5}
// Another way to do the same thing
AEval( aArray, {|x,i| x := i },,, .T. )
// aArray is {1,2,3,4,5}
aArray := Directory("*.PRG") // list file names
AEval( aArray, {|a| QOut( a[F_NAME] ) } )
USE Customer NEW // read data from a
aArray := Array( FCount() ) // DBF file into an array
AEval( aArray, {|x,i| aArray[i] := ;
{ PadR( FieldName(i), 10) , ;
FieldGet(i) ;
} ;
} )
// display data
AEval( aArray, {|a| QOut(a[1]+":", a[2]) } )
CLOSE Customer
RETURN
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.