CFLib.org – Common Function Library Project

clearStructureNested(s)

Last updated January 28, 2005

author

Qasim Rasheed

Version: 1 | Requires: CF6 | Library: DataManipulationLib

Description:
This function recurse through a structure and makes all fields as empty string

Return Values:
Returns a structure.

Example:

<cfset foo = structnew()>
<cfset foo.foo = structnew()>
<cfset foo.foo.foo = "bar">
<cfset foo.test = "bar">
<cfset clearStructureNested( foo )>
<cfdump var="#foo#">

Parameters:

Name Description Required
s Structure to clear. Yes

Full UDF Source:

<!---
 This function recurse through a structure and makes all fields as empty string
 
 @param s      Structure to clear. (Required)
 @return Returns a structure. 
 @author Qasim Rasheed (qasimrasheed@hotmail.com) 
 @version 1, January 28, 2005 
--->
<cffunction name="clearStructureNested" returntype="void" output="false">
    <cfargument name="s" type="struct" required="true" />
    <cfset var i = "">
    <cfloop collection="#arguments.s#" item="i">
        <cfif isstruct(arguments.s[i])>
            <cfset clearStructureNested(arguments.s[i])>
        <cfelse>
            <cfset structupdate(arguments.s, i,"")>
        </cfif>
    </cfloop>
</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson