| Reference > Rule Languages > Business Action Language > BAL Constructs > definitions |
definitions |
PREVIOUS NEXT |
Introduces the part of the rule that lets you define variables.
definitions
set <variable> to <definition> [in <list> / from <object>] [where <test>*] ;*
Variables allow you to write more concise rules by using a short, convenient identifier to represent a value or the result of an expression.
Variables defined in the definitions part of a rule are local to the rule in which they are defined. A local variable can be used anywhere within this same rule, but is not available in other rules. You define local variables using the set <variable> to <definition> construct.
You can also define global input/output variables (called ruleset parameters) at the application or rule project level. Ruleset parameters are accessible to any of the rules in your project. Ruleset parameters are created and edited in Rule Studio.
The following example declares the local variable `preferred customer' in the definitions part of the rule and uses it in the if and then parts of the rule.
definitions set 'preferred customer' to a customer; if the age of 'preferred customer' is less than 18 then apply a 10% discount to the shopping cart of 'preferred customer';
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |