| Reference > Rule Languages > Business Action Language > BAL Constructs > called <variable> |
called <variable> |
PREVIOUS NEXT |
Provides a name for a variable declared in a for each action statement.
called <variable>,
When using a for each statement to perform an action on a set of items, a variable is created automatically to allow you to refer to each item in turn as `this item' (see the first example below). However, if you nest one for each loop inside another, you must give the variable in the outer loop a name so that you can reference it from within the inner loop (see the second example below).
The following rule shows a simple for each action statement. There is no need to use the called construct in this case.
if
the category of the customer is Gold
then
for each customer in ‘senior customers’:
- send flowers to this customer;
The following rule shows two nested for each statements. The called construct is used so hat each customer can be explicitly referred to from within the nested for each loop.
if the category of the customer is Gold then for each customer called c, in ‘senior customers’: - for each account in ‘new accounts’: - send a statement for this account to the mailing address of c;
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |