Body clause


Use a body clause in a rule to call slot assignments, primitives, or functions. In a body clause, functions return an expression, and primitives return a Boolean value expressing the success or failure of the primitive.

For more information about primitives and functions, see MRL-functions-and-primitives.

Warning

Note

When a primitive fails, that is, returns the value FALSE, the remainder of the block is not executed.

The syntax of the body clause is as follows:

{
   <Variable>.<SlotName> = <Value>;
   <Call> ;
}
Warning

Note

Except for the last statement, all statements in a body clause must be separated by using a semicolon (;).

The syntax to call a slot assignment in a body clause is as follows:

$EV.<SlotName> = <expression>

if-then-else construct

The if-then-else construct is a special call used in a body clause that specifies a conditional execution. The syntax for the if-then-else construct is as follows:

if <Expression>
then
   {
      <Variable>.<SlotName> = <Value>
      <Call>
   }
[ else
      {
         <Variable>.<SlotName> = <Value>
         <Call>
      }
   ]

The else body clause is optional. If the Expression is evaluated as true, the statements in the then block are executed. However, if an else block is included in the body clause and the statement is evaluated as false, the statements in the else block are executed.

You can refer to a local variable declared in the then and else block after the if-then-else call if the variable is declared in both the then and else block with the same data type, as shown in the following example:

if _Boolean expression_ then
   {
      ...
      $TEMP = ' yes' ;
      ...
   }
else
   {
      ...
      $TEMP = ' no';
      ...
   };
$EV.msg = $TEMP;

It is unnecessary to use an if-then-else construct to create a conditional affectation. A simpler solution is to use a conditional expression.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC ProactiveNet 9.6