variables
The variables keyword declares variables.
Purpose
This keyword is used to declare the variables that are associated with a ruleset.
Context
Packages
Syntax
variables {
typeName variableName [= value];
...
}
Description
You can declare the variables that are attached to a package. You can then reference these variables in rules, tasks, and functions, and in other variable initialization. You can use variables defined in a package from another package as soon as these variables are referenced with their fully qualified name or imported with the use keyword. The default package can also use other packages.
A fully qualified name is the short name of the variable prefixed with its package name.
use statements are at the same place as import statement in IRL code.
Example
package pricing
{
variables {
Customer customer;
}
rule isEligible
{
when {
...
}
then {
out.println("Customer is " + customer.name);
}
}
}
package europe.pricing
{
use pricing.*;
ruletask main
{
initialaction {
out.println("Customer is " + customer.name); customer is the variable of
the pricing package.
}
body {
isEligible
}
}
}
The pricing package has defined a customer variable. This variable is used in a rule that belongs to the pricing package. The europe.pricing package uses the pricing package. Therefore, all pricing artifacts are visible in the europe.pricing package, (for example, the customer variable).