<while>

Purpose The <while> statement is used to loop repeatedly while a condition is true. At each iteration of the loop some Superx++ statements can be executed.
Format <while>
   <cond>
      {loop condition}
   </cond>
   {iteration statements}
</while>
{loop condition} the condition to be evaluated: if true then the loop will continue; if false then the loop will terminate.
{iteration statements} the statements to be executed with each iteration of the loop.
Example #1 <class name="XEmployee" inherit="">
   <construct />
   <scope type="public">
      <var name="MyCount" type="int">0</var>
   </scope>
</class>
<node name="MyEmp" class="XEmployee" />
<while>
   <cond>
      <eval>
         <parm type="int" name="b">10</parm>
         <parm type="int" name="a"><eval object="MyEmp" member="MyCount" /></parm>
         <expr>a &lt;= b</expr>
      </eval>
   </cond>
   <xout>\r\nWhile\tinstance = </xout>
   <xout><eval object="MyEmp" member="MyCount" /></xout>
   <eval object="MyEmp" member="MyCount">
      <eval>
         <parm type="int" name="b"><eval object="MyEmp" member="MyCount" /></parm>
         <expr>b + 1</expr>
      </eval>
   </eval>
</while>

The loop starts execution and executes the <cond> clause to see whether or not it should continue processing. After that it executes the {iteration statements}. In this case the following text is sent to the output stream:

while instance = 0
while instance = 1
while instance = 2
while instance = 3
while instance = 4
while instance = 5
while instance = 6
while instance = 7
while instance = 8
while instance = 9
while instance = 10

Example #2 <class name="XEmployee" inherit="">
   <construct />
   <scope type="public">
      <var name="MyCount" type="int">0</var>
   </scope>
</class>
<node name="MyEmp" class="XEmployee" />
<while>
   <cond>
      <eval>
         <parm type="int" name="b">10</parm>
         <parm type="int" name="a"><eval object="MyEmp" member="MyCount" /></parm>
         <expr>a &lt;= b</expr>
      </eval>
   </cond>
   <xout>\r\nWhile\tinstance = </xout>
   <xout><eval object="MyEmp" member="MyCount" /></xout>
   <if>
      <cond>
         <eval>
            <parm type="int" name="a">5</parm>
            <parm type="int" name="b"><eval object="MyEmp" member="MyCount" /></parm>
            <expr>a = b</expr>
         </eval>
      </cond>
      <true>
         <xout>\r\nBreak: If\tinstance = </xout>
         <xout><eval object="MyEmp" member="MyCount" /></xout>
         <break />
      </true>
      <false />
   </if>
   <eval object="MyEmp" member="MyCount">
      <eval>
         <parm type="int" name="b"><eval object="MyEmp" member="MyCount" /></parm>
         <expr>b + 1</expr>
      </eval>
   </eval>
</while>

The loop starts execution and executes the <cond> clause to see whether or not it should continue processing. After that it executes the {iteration statements}. Please note that the <break> statement will terminate the loop prematurely. In this case the following text is sent to the output stream:

while instance = 0
while instance = 1
while instance = 2
while instance = 3
while instance = 4
while instance = 5
Break: If instance = 5