House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Talk (CF-Talk)

udf var

Author:
Josh Nathanson
03/06/2007 08:24 PM

Will - the form scope is available to your function already, that's why it says can't declare variable twice.  Try using "frm" or something similar for the name of your argument to avoid confusion.  You still pass in the form scope, but just call it something different within your function. -- Josh >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 > >


Search cf-talk

March 22, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31