| Reference > Rule Languages > ILOG Rule Language > IRL Keywords > continue |
continue |
PREVIOUS NEXT |
A right-hand side statement for skipping an iteration. This keyword is used in rule actions or functions.
continue;
The continue statement is used in the action part of a rule and in a function. It permits you to skip an iteration of a loop, either a while loop or a for loop. This statement forces the ILOG JRules rule engine to skip to the next test of the loop statement.
rule StockDropWarning {
when {
?c:Client(?a:account_number;?p:percentWarningMark);
ClientStockList(account_number == ?a; ?s:stockList);
}
then {
Enumeration ?enum = ?s.elements();
while (?enum.hasMoreElements()) {
Stock ?x = (Stock)enum.nextElement();
if (?x.type == Stock.LONG)
continue;
if ( ((1.-?p)*?x.purchasePrice) > ?x.currentPrice ) {
System.out.println("Dear "+ ?c.name + " Your stock "
+ ?x.ticker + " has dropped " +
((?x.purchasePrice - ?x.currentPrice) /
?x.purchasePrice ) + " percent.");
}
}
}
};
The rule StockDropWarning checks the percent change of a client's stocks and warns if a stock price dropped by more than a certain percentage. The condition Client returns an account number in variable ?a and a decimal value percentWarningMark in variable ?p. The second condition, ClientStockList, returns a stock list in variable ?s corresponding to the account number equal to ?a. In the action part of the rule, the while statement is used to iterate over every stock in the stock list ?s.If a stock type is equal to LONG, the continue statement cause the iteration to skip the rest of the statements in the while block and proceed to the while test. If a stock type is not equal to LONG, the difference between the purchase price and the current price is calculated. If the stock price decreased in ?p percent below the purchasePrice, a message is printed.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |