[attrname := ] EVALUATE(expression) ;
[attrname := ] EVALUATE(module [, defname ] ) ;
[attrname := ] EVALUATE(engine , expression ) ;
| 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 or an expression that resolves to data (either a dataset or a scalar value). |
| module | The module to evaluate. |
| engine | The engine on which to evaluate. Valid options are ECLAGENT (for hThor) or the name of a Thor queue. |
| 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.
The third form of the EVALUATE action evaluates the expression on the specified engine. This option is disabled by default, to enable it, use:
#OPTION('enableClusterHopping', TRUE);Examples:
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 := OUTPUT(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: RichardForm 3 example:
#OPTION('enableClusterHopping', TRUE);
MyLayout := RECORD
UNSIGNED4 id;
STRING20 n;
END;
ds1 := DATASET([{100,'Fred'},
{101,'Wilms'},
{102,'Barney'},
{103,'Betty'},
{104,'Dino'}], MyLayout);
ds2 := DATASET([{100,'Miami'},
{101,'Hollywood'},
{102,'Miami'},
{103,'Fort Lauderdale'},
{104,'Hialeah'}], MyLayout);
JoinData(DATASET(MyLayout) d1, DATASET(MyLayout) d2) := JOIN
(d1,d2,LEFT.id = RIGHT.id,TRANSFORM
({UNSIGNED4 id,
STRING20 n1,
STRING20 n2},
SELF.id := LEFT.id,
SELF.n1 := LEFT.n,
SELF.n2 := RIGHT.n));
OUTPUT(EVALUATE('mythor1', JoinData(ds1, ds2)), NAMED('mythor1'));
OUTPUT(EVALUATE('mythor2', JoinData(ds1, ds2)), NAMED('mythor2'));
OUTPUT(EVALUATE('ECLAGENT', JoinData(ds1, ds2)), NAMED('ecl_agent'));See Also: APPLY, SERVICE Structure,