Variable Definitions are those whose value can be assigned in actions of rules. You can create variable definitions on primitive data types and Java objects.
Consider a Variable Definition as follows:
Name |
Type |
Initial Value |
---|---|---|
X |
int |
0 |
This Variable Definition can be used in an action in an If-Then rule as follows:
If |
|
... |
|
Then |
|
Assign:: x = x + 10 |
Many rules involve calculation of a crucial output parameter that is modified by other rules. In such cases the output parameters can be modified in those rules.
Example
To calculate interest rate, you can create a Variable Definition as follows:
Name |
Type |
Initial Value |
---|---|---|
double |
Int Rate |
0 |
The Variable Definition can be used in an action in an If-Then Rule as follows:
Assign :: Int Rate = 10.5
Assign :: Int Rate = Int Rate + 5
Some actions may return intermediate values that need to be used as input for other actions. This can be achieved by using variable definitions.
Example
Consider a Variable Definition as follows:
Name |
Type |
Initial Value |
---|---|---|
Temp |
int |
0 |
This Variable Definition can be used as follows:
If |
|
... |
|
Then |
|
Assign :: Temp = performaction1 () |
|
performaction2 (Temp) |
Variable Definitions can be used in conditions. When Variable Definition used in 'Assign' actions cause the values of those variable definitions to change, then these Definitions used in conditions are re-evaluated . Based on the outcome then rules are appropriately removed from or added to the Firing Queue.