Monday May 29, 2017

      SteelArrow Basics
      SteelArrow Tags
  SteelArrow Functions
  SteelArrow Objects
  Advanced Topics
  WAS Overview
  Code Samples
  Site Search

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 --->
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:

<SAWHILE COND=count .lt. 10>
   <SAOUTPUT VALUE=count><br>
   <SASET NAME=count VALUE=count + 1>
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:

<SALOOP COND=count .lt. 10>
   <SAOUTPUT VALUE=count><br>
   <SASET NAME=count VALUE=count + 1>

<!--- Another example without COND --->
<!--- The NAME attribute is the index --->
<SALOOP FROM=0 TO=10 NAME=count>
   <SAOUTPUT VALUE=count><br>


Copyright © 1998-2004 Tomahawk Technologies Inc.
Privacy Policy