You're mixing up the global Form scope, with your Arguments.Form struct, and the idea of var scoping function-local variables.
You're also missing half the point of creating functions: abstracting and modularising common functionality - what happens if you want to trim another scope or structure? Here's a function that does what you want, but can also be used against Url scope, Session scope, or any structure you like. <cffunction name="trimStruct" returntype="Struct" output="false" access="public"> <cfargument name="aStruct" type="Struct"/> <cfset var Item = ""/> <cfloop item="Item" collection="#Arguments.aStruct#"> <cfset Arguments.aStruct[Item] = Trim(Arguments.aStruct[Item])/> </cfloop> <cfreturn Arguments.aStruct/> </cffunction> <cfset Form = trimStruct(Form)/> <cfset Url = trimStruct(Url)/> <cfset A_Random_Structure = trimStruct(A_Random_Structure)/> Hope that helps? > I haven't built a simple udf in forever, but decided to do one for my > trimming of formfields. I tried sticking a <cfset var form = ""> right > above the loop, but I get an error: > > Cannot declare local variable FORM twice. > > <cfcomponent> > <cffunction name="cleanFormfields" access="public" > returntype="struct"> > <cfargument name="form"> > <cfloop list="#ARGUMENTS.FORM.fieldnames#" > index="thisfield"> > <cfset FORM[thisfield] = Trim(ARGUMENTS.FORM[thisfield])> > </cfloop> > <cfreturn form> > </cffunction> > </cfcomponent> > > Am I not supposed to var this one? > > Thanks, Will ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion MX7 and Flex 2 Build sales & marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271845 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4