<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFLOOP: CONDITIONAL LOOP</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="Description">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFLOOP: CONDITIONAL LOOP</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Description</span>
<p>
A conditional loop iterates over a set of instructions as long as a condition is True. To use this type of loop correctly, the instructions must change the condition every time the loop iterates, until the condition is False. Conditional loops are known as WHILE loops, as in, &quot;loop WHILE this condition is true.&quot;
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">Syntax</span><pre>&lt;cfloop 
   condition = &quot;expression&quot;&gt;
   ...
&lt;/cfloop&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">See also</span>
<p>
cfabort, cfbreak, cfexecute, cfexit, cfif, cflocation, cfswitch, cfthrow, cftry; "cfloop and cfbreak" in Chapter&#160;2, "Elements of CFML," in ColdFusion MX Developer's Guide
</p>

<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">Example</span>
<p>
The following example increments CountVar from 1 to 5. 
</p>
<pre>&lt;!--- Set the variable CountVar to 0. ---&gt; 
&lt;cfset CountVar = 0&gt;
&lt;!--- Loop until CountVar = 5. ---&gt;
&lt;cfloop condition = &quot;CountVar LESS THAN OR EQUAL TO 5&quot;&gt;
   &lt;cfset CountVar = CountVar + 1&gt;
   The loop index is &lt;cfoutput&gt;#CountVar#&lt;/cfoutput&gt;.&lt;br&gt;
&lt;/cfloop&gt;
</pre>
<p>
The output of this loop is as follows: 
</p>
<pre>The loop index is 1.
The loop index is 2. 
The loop index is 3. 
The loop index is 4. 
The loop index is 5. 
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="CONDITION">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">CONDITION</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">Required</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Condition that controls the loop.</p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
