| Reference > Rule Languages > ILOG Rule Language > IRL Keywords > break |
break |
PREVIOUS NEXT |
A right-hand side statement for exiting a loop. This keyword is used in functions or technical rule actions.
break;
The break statement is used in the action part of a rule and in a function. It permits you to exit a loop, either a while loop or a for loop. This statement forces the ILOG JRules rule engine to skip to the end of the containing statement block and continue to the next instruction.
rule AlarmSurveillance {
when {
?a: Alarm(state == NEW);
}
then {
modify ?a {
state = ON;
}
while (?a.state == ON ) {
...
if (?a.level == 3)
break;
}
}
};
The AlarmSurveillance rule tests for a new Alarm object and loops while the state is equal to ON unless the level is equal to 3. The single rule condition matches an object Alarm if the field state equals the static value NEW. If such a Alarm object is matched, the action part can be executed. The modify statement is used to change the field state from NEW to ON. The while statement is used to loop as long as the field state has the value ON. An if statement tests the field level. If the level is equal to 3, a break is executed and the program exits the while loop.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |