Three types of Rules can be called:
- External Rules: They are defined at the Library level and are called by their names, and a list of arguments corresponding to their signatures.
RuleName(<FirstArgument>,<SecondArgument>,…);
- Local Rules: They are EKL scripts that can access the Attributes and Children of the current Concept.
Rule
{
<EKL statements>
};
- Event-triggered Rules: There are two kinds of Event-Triggered Rules.
- The "On Init" Rules (only one can be defined for each Concept) can be used to do a pre-treatment on KML Objects instantiated from the Concept. They are executed as soon as the KML Object is created.
Rule on Init
{
<EKL statements>
}; - The "On Valuation" Rules which can be used to do a post-valuation treatment on a set of attributes. They are executed only when every input and specified attribute are evaluated on an object. They can be a powerful tool when debugging for example.
/* This rule will be executed only when Objects a and c are evaluated */
Rule on Valuation Object, a
{
let b(Integer)
c = b / 2
Message(“Object has name #, a has value # and b/2 = #”,Object.Name, a,c)
};
|
Local and External Rules have Inputs and Outputs parameters. This information is used to determine what Rule should be called to evaluate an Attribute/Child during the KML process. The number of Rules called is not limited. An attribute can be the Output of only one Rule but can be used as Input for any Rule.
Rules
{
External Rules
{
Add(a,b,c); /* a and b are Inputs for the Add Rule, c is Output */
}
Rule /* Local Rule */
{
let i = 1
c = 0
for i while i <= b
{
c = c + a
}
};
Rule on Init /* Initialization Rule */
{
/* Provides acceptable values for a String attribute named CarColor */
let acceptableValues(List)
If Owner.CarType == “FluoCar”
{
acceptableValues.Append(“Green”)
acceptablevalues.Append(“Yellow”)
}
else
{
acceptableValues.Append(“Red”)
acceptableValues.Append(“White”)
acceptableValues.Append(“Black”)
}
CarColor.AuthorizedValues = acceptableValues
};
}