if

Purpose The if statement is used to compare an item against a single set of criteria and to perform a set of statements based on the result of the comparison. It differs from the switch statement in that the if statement performs only one of two consequential sets of statements, whereas the switch statement can perform more than one consequential set of statements.
Format if({comparison clause}) {
      {true consequence}
};

if({comparison clause}) {
      {true consequence}
} else {
      {false consequence}
};

{comparison clause} an expression that evaluates to a boolean value-- i.e. true or false.
{true consequence} (optional) the set of statements to be executed if the comparison yielded true.
{false consequence} (optional) the set of statements to be executed if the comparison yielded false.
Example #1 node MyPal {
   <Age>23</Age>
};
if (23 = $MyPal/Age) {
   xout("You are 23");
} else {
   xout("You are not 23");
};

The MyPal object is instantiated and contains the child object Age with a value of 23. The comparison clause of the if statement executes and yields true because both values equal each other. This causes the execution of the true consequence which sends the following text to the output stream: You are 23.

Example #2 node MyPal {
   <Age>27</Age>
};
if (23 = $MyPal/Age) {
   xout("You are 23");
} else {
   xout("You are not 23");
};

The MyPal object is instantiated and contains the child object Age with a value of 27. The comparison clause of the if statement executes and yields false because the values are different. This causes the execution of the false consequence which sends the following text to the output stream: You are not 23.