This example employs a COM object to output a list of files. In this example, FFUNC is a collection of file2 objects.
<CFOBJECT CLASS=FileFunctions.files
NAME=FFunc
ACTION=Create>
<CFSET FFunc.Path = "c:\">
<CFSET FFunc.Mask = "*.*" >
<CFSET FFunc.attributes = 16 >
<CFSET x=FFunc.GetFileList()>
<CFLOOP COLLECTION=#FFUNC # ITEM=file2>
<CFOUTPUT>
#file2.name# <BR>
</CFOUTPUT>
</CFLOOP>
This example loops through a structure (used as an associative array):
...<!--- Create a structure and loop through its contents --->
<CFSET Departments=StructNew()>
<CFSET val=StructInsert(Departments, "John", "Sales")>
<CFSET val=StructInsert(Departments, "Tom", "Finance")>
<CFSET val=StructInsert(Departments, "Mike", "Education")>
<!--- Build a table to display the contents --->
<CFOUTPUT>
<TABLE cellpadding="2" cellspacing="2">
<TR>
<TD><B>Employee</B></TD>
<TD><B>Dept.</B></TD>
</TR>
<!--- In CFLOOP, use ITEM to create a variable
called person to hold value of key as loop runs --->
<CFLOOP COLLECTION=#Departments# ITEM="person">
<TR>
<TD>#person#</TD>
<TD>#StructFind(Departments, person)#</TD>
</TR>
</CFLOOP>
</TABLE>
</CFOUTPUT>
...
|