Purpose | The <do> ... <cond> statement is used to loop repeatedly while a condition is true. At each iteration of the loop some Superx++ statements can be executed. | |||||
Format |
<do> {iteration statements} <cond> {loop condition} </cond> </do> {iteration statements} |
the statements to be executed with each iteration of the loop. |
{loop condition} |
the condition to be evaluated: if true then the loop will continue; if false then the loop will terminate. |
|
|
Example #1 |
<class name="XEmployee" inherit=""> <construct /> <scope type="public"> <var name="MyCount" type="int">0</var> </scope> </class> <node name="MyEmp" class="XEmployee" /> <do> <xout>\r\nDo ... Cond\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> <cond> <eval> <parm type="int" name="b">10</parm> <parm type="int" name="a"><eval object="MyEmp" member="MyCount" /></parm> <expr>a <= b</expr> </eval> </cond> </do>
The loop starts execution with the {iteration statements} and then executes the <cond> clause to see whether or not it should continue processing. In this case the following text is sent to the output stream: |
|||||
Example #2 |
<class name="XEmployee" inherit=""> <construct /> <scope type="public"> <var name="MyCount" type="int">0</var> </scope> </class> <node name="MyEmp" class="XEmployee" /> <do> <xout>\r\nDo ... Cond\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> <cond> <eval> <parm type="int" name="b">10</parm> <parm type="int" name="a"><eval object="MyEmp" member="MyCount" /></parm> <expr>a <= b</expr> </eval> </cond> </do>
The loop starts execution with the {iteration statements} and then executes the <cond> clause to see whether or not it should continue processing. Please note that the <break> statement will terminate the loop prematurely. In this case the following text is sent to the output stream: |