Chapter 1: ColdFusion Tags
DELIMITERS
Optional. Specifies the delimiter characters used to separate items in the LIST.
Example
This loop will display the names of each of the Beatles:
<CFLOOP INDEX="ListElement"
LIST="John,Paul,George,Ringo">
</CFLOOP>
Although CFLOOP expects elements in the list to be separated by commas by default,
you are free to specify your own element boundaries in the DELIMITER attribute.
Here's the same loop as before, only this time CFLOOP will treat commas, colons, or
slashes as list element delimiters:
<CFLOOP INDEX="ListElement"
LIST="John/Paul,George::Ringo"
DELIMITERS=",:/">
</CFLOOP>
Delimiters need not be specified in any particular order. Note that consecutive
delimiters are treated as a single delimiter; thus the two colons in the previous example
are treated as a single delimiter between "George " and "Ringo. "
Looping over a COM Collection or Structure
The CFLOOP COLLECTION attribute allows you to loop over a structure or a COM/
DCOM collection object:
A COM/DCOM collection object is a set of similar items referenced as a group
rather than individually. For example, the group of open documents in an
application is a type of collection.
A structure can contain either a related set of items or be used as an associative
array. Looping is particularly useful when using a structure as an associative
array.
Each collection item is referenced in the CFLOOP by the variable name that you supply
in the ITEM attribute. This type of an iteration is generally used to access every object
within a COM/DCOM collection or every element in the structure. The loop is
executed until all objects have been accessed.
The COLLECTION attribute is used with the ITEM attribute in a CFLOOP. In the
example that follows, ITEM is assigned a variable called file2, so that with each cycle
in the CFLOOP, each item in the collection is referenced. In the CFOUTPUT section,
the name property of the file2 item is referenced for display.
<CFOUTPUT>#ListElement#</CFOUTPUT><BR>
<CFOUTPUT>#ListElement#</CFOUTPUT><BR>
133
Need help?
Do you have a question about the COLDFUSION 4.5-CFML LANGUAGE and is the answer not in the manual?