Reference > Rule Languages > ILOG Rule Language > IRL Keywords > functiontask

Summary

The keyword used to declare a function task. This keyword is used at the top level of the ruleset.

Syntax

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

Description

A function task is one of the three kinds of tasks available in a ruleflow. A function task defines a ruleflow function.

Notes
  1. The ruleflow syntax is described in Syntax of a Ruleflow.
  2. If a formal comment (/**...*/) precedes the task definition, it is saved so that it may be retrieved later using the API.

Example

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 example defines a function task whose body is the code given between the braced brackets. 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.

See Also

body (in Function Task), flowtask, ruletask