<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>
   <cond>
      {comparison clause}
   </cond>
   <true>
      {true consequence}
   </true>
   <false>
      {false consequence}
   </false>
</if>
{comparison clause} an <eval> statement 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 name="MyPal">
   <Age>23</Age>
</node>
<if>
   <cond>
      <eval>
         <parm type="int" name="age">23</parm>
         <parm type="int" name="a">
            <eval object="MyPal/Age" />
         </parm>
         <expr>a = age</expr>
      </eval>
   </cond>
   <true>
      <xout>You are 23</xout>
   </true>
   <false>
      <xout>You are not 23</xout>
   </false>
</if>

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

Example #2 <node name="MyPal">
   <Age>27</Age>
</node>
<if>
   <cond>
      <eval>
         <parm type="int" name="age">23</parm>
         <parm type="int" name="a">
            <eval object="MyPal/Age" />
         </parm>
         <expr>a = age</expr>
      </eval>
   </cond>
   <true>
      <xout>You are 23</xout>
   </true>
   <false>
      <xout>You are not 23</xout>
   </false>
</if>

The MyPal object is instantiated and contains the child object Age with a value of 27. The <cond> clause of the <if> statement executes and yields false because the values do not equal each other. This causes the execution of the <false> clause which sends the following text to the output stream: You are not 23.