Variables in rules
Use variables in rules to point to MRL objects, such as events, data, global records, or interfaces, and to reference results returned by a primitive.
In a rule, you must declare variables at their first occurrence in the text. The scope of the variable is from its declaration to the end of the rule. The value for a variable cannot change during the life of the variable. For example, you cannot assign another value to a variable after the first occurrence in a rule.
The syntax for a declaring a variable is as follows:
The name of the variable must be composed of alphanumeric characters; it also can contain the underscore character.
In the following example, the variable $EV points to the event being evaluated so that $EV.SlotName refers to the slot of the specified name for that event. The slot must exist in the BAROC definition of that object class. You then can use the $EV variable in expressions in the rule or in assignment statements.
[<expression> <op> <expression>,
. . . ,
<expression> <op> <expression> ]
Global record instances are predefined in the Knowledge Base; therefore, the scope of global record variables is the entire Knowledge Base. A variable $UNDER_MAINTENANCE refers to the unique instance of the UNDER_MAINTENANCE global record. You can use variables in primitives to obtain the values they return, as shown in the following example:
$EV.msg = $MSG ;
The concat primitive concatenates a list of strings into another string. The $MSG variable obtains the result, so that the concatenated string can be used in subsequent clauses. The result is used as an assignment.