Evaluating Selected DB Elements
- Last UpdatedOct 24, 2022
- 2 minute read
Using the facilities described here you can create an expression and have it evaluated for all elements which satisfy particular selection criteria. The results of the expression are then placed in a named array.
The command syntax is:
VAR !Array EVALUATE (Expression) FOR select COUNTVAR !Counter
Where:
|
!Array |
This is the name of the array that will be created to contain the results of (expression) for all the elements selected within select. |
|
(expression) |
This is the expression that will be carried out for all the elements that match the select criteria. |
|
select |
This is the selection criteria (see above, and the relevant Reference Manual for the product for details of selection criteria). |
|
COUNTVAR |
This is an optional command which allows you to record how often the expression is calculated in Counter, which is increased by one each time the expression is evaluated. |
You can append the results of such an evaluation to an existing array using the APPEND keyword. For example:
VAR !BOXES APPEND EVALUATE ( XLEN*YLEN ) FOR ALL BOXES
This will add the values calculated from the expression for all BOXES to the (already existing) array BOXES.
You can also overwrite elements in the array by specifying the first index in the array which you want to be overwritten. The specified index, and the indices following it, will be overwritten by the results of the evaluation. For example:
VAR !BOXES[99] EVALUATE ( XLEN*YLEN ) FOR ALL BOXES
This will place the result of the first evaluation for the selected elements at index 99, overwriting any existing item, and the following results in the subsequent array elements.