Perhaps what was meant was that instead of using:
<cfparam name="a_var" default="1">
you should use:
<cfif Not IsDefined("a_var")>
<cfset a_var = 1>
</cfif>
when you're initializing variables which may already exist.
I've heard the second version is sligtly faster. Although in practice I
haven't really been able to observe much difference either way.
Of course in the situation where you want to be sure a variable is null
(""), obviously cfset is the only way to go.
</rob>
-----Original Message-----
From: Gyrus [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 24, 2002 9:36 AM
To: CF-Talk
Subject: setting empty vars - CFSET or CFPARAM? (was: Reg Expr help)
> I can't remember where I saw it/read it; but it was form a MM guy (or
on
> a course), that you really shouldn't use <cfset to set an empty
> variable, you should use <cfparam>
Would be nice to know the rationale behind this - anyone?
The example I gave was setting a empty string to start a blank list,
which would be built up gradually. I can imagine scenarios where maybe
the list has already been created, and you want to keep any existing
values but create the variable as empty if it doesn't exist. This would
be a good use of CFPARAM.
But maybe you want to make sure the list starts blank and you *don't*
want to keep any old values in there. Surely <cfset list=""> would be
best here?
Can't understand why there would be a cover-all rule-of-thumb for using
CFPARAM for setting blank vars when the context should really dictate
what's used.
- Gyrus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- [EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://www.norlonto.net
- PGP key available
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.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