Calculation as a comparison in a condition
- Last Updated: March 24, 2021
- 2 minute read
- Corticon
- Version 7.2
- Documentation
After planWeight is derived by the
nonconditional calculation in the following figure, it can immediately be used elsewhere in
this or subsequent Rulesheets.
An example of such usage appears in the following figure:
planWeight Derived and used in same
Rulesheet
In Condition row a, planWeight is compared
to the aircraft's grossWeight to make sure that the
aircraft is not overloaded. An overloaded aircraft must not be allowed to fly, so the
approved attribute is assigned a value of false.
This has the advantage of being both clear and easy to reuse—the term
planWeight, once derived, can be used anywhere to
represent the data produced by the calculation. It is also much simpler to use a single
attribute in a rule expression than it is a long, complicated equation.
But, this does not mean that the equation cannot be modeled in a
conditional expression, if preferred. The example shown in the following figure places the
calculation in the LHS of the Conditional comparison to derive planWeight and compare it to grossWeight all
in the same expression.
This approach might be preferable if the results of the calculation were not
expected to be reused, or if adding an attribute like planWeight to the Vocabulary were not possible. Often, attributes like planWeight are very convenient intermediaries to carry
calculated values that will be used in other rules in a Rulesheet. In cases where such
attributes are conveniences, and are not used by external applications consuming a
Rulesheet, they can be designated as transient attributes in the Vocabulary, which causes
their icons to change from blue/yellow to orange/yellow.