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

Summary

A ruleflow statement for jumping to another ruleflow statement. This keyword is used in the flowtask body.

Syntax

goto label;

Description

The goto statement is a ruleflow statement that gives the option of jumping to another statement in the ruleflow. The target statement must be labeled, and this label is the one referenced in the goto statement.

A goto statement can be used in a fork or while statement if the following rules are respected:

Example

flowtask main
{
   body =
   {
      start: if (turn == Constants.Player1) ChooseMovePlayer1;
               else ChooseMovePlayer2;
               CheckMove;
               if (ending) goto end;
               UpdateDistance;
               ExpandObjects;
               DetectConnect4;
               if (ending)  goto end;
               DetectGridFull;
               if (ending)  goto end;
               ChangeTurn;
               goto start;
      end: EndOfGame;
   }
};

The ruleflow consists of a loop implemented with the goto statement goto start, which jumps to the beginning of the flow. The loop can be interrupted under some conditions, and this interruption is implemented with goto statements goto end; start and end are the labels of the first and last ruleflow statements, respectively.

See Also

body (in Flow Task), flowtask