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:

$<VariableName>

The name of the variable must be composed of alphanumeric characters; it also can contain the underscore character.

Note

The cell uses a naming convention of variables with short uppercase names.

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.

<ClassName> ($EV) where 
   [<expression> <op> <expression>, 
   . . . , 
   <expression> <op> <expression> ]

Note

The same principles that apply to events also apply to interface objects: a variable points to the interface instance returned by an external program. Additionally, it allows the use of the individual slot values in subsequent expressions.

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:

concat( ['from top', 'to bottom' ], $MSG0; 
$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.

Was this page helpful? Yes No Submitting... Thank you

Comments