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

Summary

The keyword used to declare a flow task. This keyword is used at the top level in the ruleset.

Syntax

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

Description

A flow task is one of the three kinds of tasks available in a ruleflow. A flow task describes how task executions are chained together and under which conditions.

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.

sequence, if, switch, while (break and continue), fork, goto.

Example

flowtask main
{
   initialaction =
   {
      turn = Constants.Player2;
      saved = new SavedGame(grid);
      for (var i = 0; i < 7; i++) for (var j = 0; j < 6; j++)
      insert(grid.array[i][j]);
   };
   finalaction =
   {
      grid = null;
      move = null;
      winner = Constants.None;
      connect4 = null;
      ending = false;
      message = null;
   };
   body =
   {
      while(!ending)
      {
         if (turn == Constants.Player1) ChooseMovePlayer1;
         else ChooseMovePlayer2;
         
         CheckMove;
         if (ending) break;
         
         UpdateDistance;
         ExpandObjects;
         DetectConnect4;
         if (ending) break;
         
         DetectGridFull;
         if (ending) break;
         ChangeTurn;
      }
      EndOfGame;
   }
};

This example illustrates a flow task definition. When this task is executed, its initial actions are executed first. Then its body is executed. The body consists of a while loop, each loop corresponding to a player's move in the Connect4 game. A player's move consists of playing a move. If this move causes a Connect4 to be accomplished or the grid to be full, then the game is finished: the while loop can be interrupted by a break statement. Here the ruleflow resumes after the while loop; in this particular example, the EndOfGame task is executed. When the flow finishes execution, the task's final actions are executed.

See Also

body (in Flow Task), functiontask, ruletask