| Reference > Rule Languages > ILOG Rule Language > IRL Keywords > flowtask |
flowtask |
PREVIOUS NEXT |
The keyword used to declare a flow task. This keyword is used at the top level in the ruleset.
flowtask flowTaskName
{
[property propertyName = value;]
[initialaction {action1 ... actionm}]
[finalaction {action1 ... actionn}]
[completionflag = value;]
body {ruleflow}
};
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 |
|
true, then 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.
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.
body (in Flow Task), functiontask, ruletask
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |