Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cfparam vs cfset, what is the difference?

369 views
Skip to first unread message

Adam Bragg

unread,
Jan 2, 2004, 6:30:57 PM1/2/04
to
I have read up on both of these but I still don't quite get the benefits
or differences. Could someone help me understand or just offer their
point of view on the subject?

blondydog

unread,
Jan 2, 2004, 10:05:58 PM1/2/04
to
CFSET is used to set the value of a variable whether the variable is already defined or not. If the variable already has a value in it, CFSET will step on that value.

CFPARAM should be used when you want to set the value of a variable only if it isn't already defined. It will not modify a variable that is already defined, leaving it at whatever value it had before the CFPARAM tag was executed.

Cheers,

Eric


Adam Bragg

unread,
Jan 3, 2004, 4:52:11 PM1/3/04
to
I get it finally. Thank you Eric for clearing that up. Man, sometimes
things are just too plain to be understood ;)

sean69

unread,
Jan 3, 2004, 5:37:00 PM1/3/04
to
just as a side note for you, your <cfparam> tag will be especially useful when using dynamic forms i.e.

<input type="text" id="id" name="variable" value="#variable#">

if you do this CF will throw a variable not found error, however if you set the <cfparam> tag,

<cfparam name="variable" default="">

the variable is defined and you will not get the error, in addition if you post that form to the same page the input boxes will "remember" thier last value as the variable is passed.

-sean


Adam Bragg

unread,
Jan 3, 2004, 5:55:57 PM1/3/04
to
Very nice. I have run into this problem and used a much less elegant
solution. So simple. Thank you.
0 new messages