|  
 
 
 | 
              | Get SteelArrow! |  |  |  |  |  | Looping Constructs 
  |  |  |  |  |  |  |  |  | 
   |  | 
         |  |  | Return to Basics Page |  |  |  | Looping constructs are not as essential as the ability to control program flow, 
            but certainly the ability to loop over data values has its place in web application
            developement.  To be able to retrieve data from a database, and display that data
            in a few lines of code is only one example of the ability looping constructs offer
            to a developer. Like the <SAIF> tag that was described in the previous section, the 
            <SAWHILE> tag has an attribute COND that describes the expression
            that is to be evaluated before the WHILE block is executed.
          The general format of the WHILE block is as follows:
          |  | 
<SAWHILE COND=expression>
   <!--- Block to execute WHILE 
        expression evaluates to TRUE --->
</SAWHILE> |  | The above sample shows how the WHILE tag is formatted.  The code contained
            within the WHILE element is the code that will be executed numerous times
            based on the expression evaluation. The following example shows the loop with some real code:
          |  | 
<SASET NAME=count VALUE=0>
<SAWHILE COND=count .lt. 10>
   <SAOUTPUT VALUE=count><br>
   <SASET NAME=count VALUE=count + 1>
</SAWHILE> |  | This code snippet will cause the WHILE expression, and code to be evaluated 
            10 times (count => 0,1,2,3,4,5,6,7,8,9). Another looping construct available in SteelArrow is the <SALOOP> element.  Its
            format is similar to WHILE in that it supports the COND attribute.  It also
            supports a FROM and TO attribute.
          The following example shows the use of LOOP:
          |  | 
<SASET NAME=count VALUE=0>
<SALOOP COND=count .lt. 10>
   <SAOUTPUT VALUE=count><br>
   <SASET NAME=count VALUE=count + 1>
</SALOOP>
<!--- Another example without COND --->
<!--- The NAME attribute is the index --->
<SALOOP FROM=0 TO=10 NAME=count>
   <SAOUTPUT VALUE=count><br>
</SALOOP> |  | 
             |  |  |  |  |  
 
 
 
 |