Block Evaluation And Arrays
- Last UpdatedNov 10, 2025
- 1 minute read
A convenient way of performing the same command on each element of an array is to use block evaluation. This in effect provides a way of building your own array-methods.
There are two steps involved: first create a BLOCK object from the command text, then apply this BLOCK to that array with the EVALUATE array method. Here is an illustration:
First we create a BLOCK out of the command to be processed for each array element:
!ExtractName = object BLOCK('!MyEmployees[!Evalindex].Name')
Note that the command is enclosed in quotes. The special variable Evalindex is automatically incremented during the evaluation of the block to the index of each array element in turn. Finally, we use the Evaluate() method to invoke block processing on the array:
!Names = !MyEmployees.Evaluate(!ExtractName)
!Names will contain the names as an array of STRING elements.
Take care that the expression does in fact return a value so that new array’s elements can be created and assigned to it.
Alternatively, you may use an evaluation expression which does not return a result provided you invoke the evaluation directly without trying to assign the result. For example, if you have defined a !!Print() function the following is valid:
!Output = object BLOCK('!!PRINT(!MyEmployees[!Evalindex].Name)')
!MyEmployees.Evaluate(!Output)
Note: In this release there is no object-oriented shorthand representing ‘this element’. It is necessary to give the array name along with a subscript expression using !Evalindex.