definitions
This construct introduces the part of the rule where you define variables.
Purpose
You use this construct to define local variables that you can use elsewhere in the same rule. Use local variables to produce more concise and readable rules.
Syntax
definitions
(set <variable> to <definition> in <list> | from <object> [where <test>]
;)*
Description
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.
Example
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 from customer; if the age of 'preferred customer' is less than 18 then print "apply a 10% discount to the shopping cart of this customer";