House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

CFScript

CFSCRIPT: Do While Loop

10 Do While Loop
10.1 A Do While loop will take a comparison statement and as long as the statement returns true, the loop will run.
10.2 The comparison statement used in a Do While loop uses the same comparison logic and structure used in an IF statement.
10.3 This example will loop while i is less than 10. It has the same effect as both the For loop and While loop discussed earlier
<CFSCRIPT>
     i=1;
     Do
     {
          WriteOutput(i&' ');
          i=i+1;
     }
     While (i LTE 10);
</CFSCRIPT>
10.4 The semicolon at the end of the While statement is the only time a semicolon is used for a code construct.
10.5 The examination of the condition takes place at the end of the loop. Even if the comparison statement fails, it will not fail until at least one iteration of the loop has performed.