Does anyone have any comments on this?  I was looking for a way to 
easily trim all of the simple values in a structure and came up with the 
following, which I thought would be useful for trimming scopes like the 
form scope or the arguments scope.

It seems to work.

Rick


<cffunction name="trimStructValues" access="public" output="no" 
returnType="struct">
        <cfargument name="myStruct" type="struct" required="yes">
        <cfargument name="recurse" type="boolean" required="no" default="false">
        <cfscript>
        var cnt = 1;
        var myKeys = StructKeyArray(myStruct);
        var myKey = "";
        
        for (cnt=1;cnt LTE arrayLen(myKeys); cnt = cnt + 1)
        {
                myKey = myKeys[cnt];
                if (isSimpleValue(myStruct[mykey]))
                {
                        myStruct[mykey] = trim(myStruct[mykey]);
                } else if ( isStruct(myStruct[mykey]) AND recurse) {
                        myStruct[myKey] = trimStructValues(myStruct[myKey]);
                }
        }
        return myStruct;
        </cfscript>
</cffunction>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:212636
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to