Yes, as you realise IncrementValue() should generally be avoided. cfparam
should not be used to initialise a variable unless it is intended that the
variable already have a value. cfparam is only there to provide a default.
To illustrate the problem, imagine several of these loops with cfparam out
front. The first would work OK but the next cfparam wouldn't do anything as
there would already be a value defined for foo.

But why not simply write <cfloop index="foo" from="1" to="whatever"> ? I
assume you have some good reason why not, but we have no idea what it is!


----- Original Message -----
From: "Robertson-Ravo, Neil (REC)" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, August 02, 2002 8:28 PM
Subject: Increments


> Opinions please...
>
> I have unenviable task of going through an old app and getting together
some
> kind of spec from which it can be improved.....  I am noticing a hell of a
> lot of variable increments performed in the following way :
>
> <cfset foo = 0>
> <cfloop......>
> <!--- loop data --->
> <cfset foo = foo + 1>
> </cfloop>
>
> now, generally I would use IncrementValue(foo) for this procedure, and in
> fact I have also noted that the CF best practice is to use this as
well.....
> comments anyone? would anyone do differently?  is setting foo = 0 good
> practice or is it better to set foo with a <cfparam>?
>
> Neil
> 
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to