functiontask

The functiontask keyword declares an action task.

Purpose

This keyword is used to declare an action task that defines a ruleflow function.

Note:

In product versions earlier than 7.1.x, action tasks were called function tasks.

Context

At the top level of rulesets

Syntax

functiontask functionTaskName  
{
    [property propertyName = value;] 
    [initialaction {action1 ... actionm}] 
    [finalaction {action1 ... actionn}] 
    [completionflag = value;] 
    body {ruleflow}
};

Description

An action task is one of the three kinds of tasks available in a ruleflow.

Note:
  1. The ruleflow syntax is described in Grammar specification.

  2. 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:

property

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.

initialaction, finalaction

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.

body

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.

Example

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.