It's also handy for file ops as well. Here's an example of a
recursive delete for CFMX6 since it doesn't support the
'recurse="true"' attribute like CFMX7 (the other functions it
references are in a cf6.cfc that I use):
<cffunction name="deleteDirectory" access="public"
returntype="boolean" hint="I delete a directory by looping through
the contents and deleting the files individually. I am a substitute
for CFMX7's recurse option.">
<cfargument name="directoryVar" required="true" type="string">
<cfset var directoryDeleted = false/>
<cfset var files = "" />
<cfset var folders = ""/>
<cfset var folderQ = "" />
<cfset var directoryList =""/>
<cfset var filesDeleted = false />
<cfif directoryExists(directoryVar)>
<cfdirectory action="list" directory="#directoryVar#"
name="directoryList" mode="777" />
<!--- Get Files to delete and Delete them --->
<cfset files = selectFiles(directoryList) />
<cfset filesDeleted = deleteFiles(files) />
<!--- Get Folders to process --->
<cfset folders = selectFolders(directoryList)>
<cfif folders.recordCount>
<!--- If more folders, rinse and repeat --->
<cfloop query="folders">
<cfset deleted = deleteDirectory(folders.directory & "/" &
folders.name) />
</cfloop>
</cfif>
<cfdirectory action="delete" directory="#directoryVar#" mode="777" />
<cfset directoryDeleted = true/>
</cfif>
<cfreturn directoryDeleted/>
</cffunction>
On Dec 13, 2006, at 9:28 AM, Peterson, Chris wrote:
> I was writing a render() function to return html, and I wanted an easy
> way to separate div content so that I can use xmlHTTP to refresh an
> individual div after doing an action with my data.
>
> So, I can invoke render() with its default config, then INSIDE of the
> render() function, I can invoke itself with a different argument!
>
> So, I have a case statement to look at what 'view' to output, and
> it has
> its default (the main screen), and then it has one named for each
> named
> div on the screen, and they just call back to itself again, and it
> works! Most of you have probably done this before, but I thought it
> was pretty neat that a function in a CFC can call itself from within
> itself =)
>
> Chris
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:263965
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4