Cfloop: Looping Over A List Or File - MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

cfloop: looping over a list or file

Description
Looping over a list steps through elements contained in any of these entities:
A variable
A value that is returned from an expression
A file
Syntax
<cfloop
index = "index_name"
list = "list_items"
delimiters = "item_delimiter">
...
</cfloop>
See also
cfabort, cfbreak, cfexecute, cfexit, cfif, cflocation, cfswitch, cfthrow,
cftry
Attributes
Attribute
Req/Opt
index
Required
list
Required
delimiters
Optional
Example
This loop displays four names:
<cfloop index = "ListElement"
list = "John,Paul,George,Ringo">
<cfoutput>#ListElement#</cfoutput><br>
</cfloop>
You can put more than one character in the
loop processes commas, colons, and slashes as list delimiters:
<cfloop index = "ListElement"
list = "John/Paul,George::Ringo"
delimiters = ",:/">
<cfoutput>#ListElement#</cfoutput><br>
</cfloop>
ColdFusion skips the second and subsequent consecutive delimiters between list elements. Thus,
in the example, the two colons between "George" and "Ringo" are processed as one delimiter.
To loop over each line of a file, use the tag this way:
<cfloop list="#theFile#"
index="curLine"
delimiters="#chr(10)##chr(13)#">
...
</cfloop>
238
Chapter 2: ColdFusion Tags
Default Description
In a list loop, the variable to receive next list element.
A list, variable, or filename; contains a list
Character(s) that separates items in list
delimiters
attribute, in any order. For example, this

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents