This might help you start to understand recursion. Basically just lists
every file in a directory using recursion.
<cfset initialLocation = "d:\data\paul\" />
<cfset myList(initiallocation) />
<cffunction name="myList" access="public" returntype="void" >
<cfargument name="theList" type="string" required="true" />
<cfdirectory directory="#thelist#" action="list"
name="fileList" recurse="false">
<!--- Loop over the list--->
<cfloop query="fileList">
<!--- If we fidna file display its directory and
the name of the file --->
<cfif "#type#" eq "File">
<cfoutput>Directory: #directory# Name:
#name#</br></cfoutput>
<cfelse>
<!--- If we find a directory start again
listing the files in this directory --->
<cfset myList("#theList#\#name#\") />
</cfif>
</cfloop>
</cffunction>
-----Original Message-----
From: Nick G [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 30 May 2007 5:57 AM
To: CF-Newbie
Subject: Recursion Help
I don't have much experience with recursion (just the Tower of Hanoi
example). I'm creating an application which needs to map out a directory and
create a "tree" structure. Using CFTree and CFDirectory have made the first
set of folders and files easy to do but when a folder has several
sub-folders, it's not too useful. I've read that using recursion is the way
to go but I don't know much about it other than that its a function which
calls itself. I'm not sure if this will work using CF alone. I use
cfdirectory to pull the list of files and folders, then use the cftree to
display the tree. Any help getting me started in the right direction would
be fabulous. Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:2771
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15