<html>
<head>
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFLOOP: LOOPING OVER A LIST OR FILE</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: LOOPING OVER A LIST OR FILE</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>
Looping over a list steps through elements contained in any of these entities:
</p>
<ul>

<li>A variable </li>

<li>A value that is returned from an expression</li>

<li>A file </li>
</ul>
  <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 
   index = &quot;index_name&quot;
   list = &quot;list_items&quot;
   delimiters = &quot;item_delimiter&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>
This loop displays four names:
</p>
<pre>&lt;cfloop index = &quot;ListElement&quot; 
   list = &quot;John,Paul,George,Ringo&quot;&gt; 
      &lt;cfoutput&gt;#ListElement#&lt;/cfoutput&gt;&lt;br&gt; 
&lt;/cfloop&gt;
</pre>
<p>
You can put more than one character in the delimiters attribute, in any order. For example, this loop processes commas, colons, and slashes as list delimiters:
</p>
<pre>&lt;cfloop index = &quot;ListElement&quot; 
   list = &quot;John/Paul,George::Ringo&quot; 
   delimiters = &quot;,:/&quot;&gt; 
      &lt;cfoutput&gt;#ListElement#&lt;/cfoutput&gt;&lt;br&gt; 
&lt;/cfloop&gt;
</pre>
<p>
ColdFusion skips the second and subsequent consecutive delimiters between list elements. Thus, in the example, the two colons between &quot;George&quot; and &quot;Ringo&quot; are processed as one delimiter.
</p>

<p>
To loop over each line of a file, use the tag this way:
</p>
<pre>&lt;cfloop list=&quot;#theFile#&quot; 
   index=&quot;curLine&quot; 
   delimiters=&quot;#chr(10)##chr(13)#&quot;&gt; 
   ...
&lt;/cfloop&gt;
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="INDEX">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">INDEX</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>In a list loop, the variable to receive the next list element.</p>

  </td>
  </tr>
  </table>
</div>
<div id="LIST">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">LIST</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>A list, variable, or filename; contains a list.</p>

  </td>
  </tr>
  </table>
</div>
<div id="DELIMITERS">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">DELIMITERS</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">Optional</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>Character(s) that separates items in list.</p>

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

  </body>
</html>
