flowtask
flowtask keyword declares a subflow
task.
Purpose
This keyword is used to declare a flow task.
Context
At the top level of rulesets
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.
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.
A subflow 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
A subflow 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. They consist of inline IRL code, such as IRL functions. They are similar to an IRL function with the
voidreturn type and no arguments.- completionflag
-
Deprecated feature:
Ruleflow completion flag is deprecated as of V8.6.0.0. This
feature will be removed in a future release. See Deprecated and removed features for migration details.This attribute can be used to specify a Boolean value that is evaluated after the task body finishes its execution. If this Boolean value is
true, then the task is completed; its final actions, if any, are executed, and the ruleflow execution continues. If the Boolean value returnsfalse, 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. - body
The flow task body defines a ruleflow. It consists of task calls that are chained together through control statements. The control statements are:
fork,goto,if,sequence,switch,while(breakandcontinue)
Example
This example illustrates a flow task definition.
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 task is executed in this order:
Its initial actions are executed first.
The body is executed.
The body consists of a
whileloop. Each loop corresponds to a move from a player in theConnect4game. If the move causes aConnect4object to be accomplished or the grid to be full, the game is finished and thewhileloop can be interrupted by abreakstatement. Here the ruleflow resumes after thewhileloop. In this particular example, theEndOfGametask is executed.When the flow finishes execution, the final actions of the task are executed.