The functiontask keyword declares an action task.
This keyword is used to declare an action task that defines a ruleflow function.
In product versions earlier than 7.1.x, action tasks were called function tasks.
At the top level of rulesets
functiontask functionTaskName
{
[property propertyName = value;]
[initialaction {action1 ... actionm}]
[finalaction {action1 ... actionn}]
[completionflag = value;]
body {ruleflow}
};
An action task is one of the three kinds of tasks available in a ruleflow.
The ruleflow syntax is described in Grammar specification.
If a formal comment (/**...*/) precedes the task definition, it is saved so that you can retrieve it later using the API.
An action task can have the following attributes:
Use this attribute to define a user property on the task. The engine does not interpret this property. You can retrieve its value later using the API.
An action task can have an initial or a final action, or both. Initial actions are executed before the task body. Final actions are executed after the task body. Initial and final actions for action tasks are composed of inline IRL code, such as IRL functions. They are similar to IRL functions with a void return type and no arguments.
The completionflag keyword is deprecated as of V8.0.1.
Use this attribute to specify a Boolean value that is evaluated after the task body has finished execution.
If this Boolean value is true, the task is completed: its final actions, if any, are executed and the ruleflow execution continues.
If the Boolean value returns false, the task is suspended: its final actions are not executed, the ruleflow execution is suspended, and the program returns to the caller of the ruleflow execution. When the ruleflow is executed again, it starts from this suspended task.
An action task is composed of inline IRL code, such as IRL functions. The body is similar to an IRL function with a void return type and no arguments.
This example defines an action task whose body is the code given between the braced brackets.
functiontask UpdateDistance
{
body =
{
int x = move.x;
int y = move.y;
for (var i = y + 1; i < 10; i++)
{
int p = grid.position(x,i);
if (p == null) break;
p.distance--;
update(p);
}
}
};
This code is executed when the task is called to be executed in a ruleflow.
If initial actions are provided, they are executed before the task body. If final actions are defined, they are executed after the task body.