[attrname := ] EVALUATE(expression) ;
[attrname := ] EVALUATE(module [, defname ] ) ;
attrname | Optional. The action name, which turns the action into a definition, therefore not executed until the attrname is used as an action. |
expression | The function to call in an action context. |
module | The module to evaluate. |
defname | Optional. The name of a specific definition within the module to evaluate. If omitted, all definitions in the module are evaluated. |
The first form of the EVALUATE action names an expression (typically a function call) to execute in an action context. This is mainly useful for calling functions that have side-effects, where you don't care about the return value.
The second form of the EVALUATE action recursively expands the exported definitions of the module and evaluates them. If a defname is specified, then only that definition is evaluated.
Example:
Form 1 example:
myService := SERVICE UNSIGNED4 doSomething(STRING text); END; ds := DATASET('MyFile', {STRING20 text} , THOR); APPLY(ds, EVALUATE(doSomething(ds.text))); //calls the doSomething function once for each record in the ds // dataset, ignoring the returned values from the function
Form 2 example:
M := MODULE EXPORT a := 10; EXPORT b := OUTPUT('Hello'); END; M2 := MODULE EXPORT mx := M; EXPORT d := OUTPUT('Richard'); END; EVALUATE(M2); //produces three results: // Result_1: 10 // Result_2: Hello // Result_3: Richard
See Also: APPLY, SERVICE Structure,