-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> >Can someone please explian when it would be more advantageous to
> >use setVariables instead of cfset?

In general, for static variable names, you should use cfset, or
better yet an assignment statement in a cfscript block.  Your best
use for SetVariable is when you have a dynamic name for the variable.
 Hopefully an example will illustrate:

<!--- This is good: --->
<cfset Whatever1 = 42>
<cfset Whatever2 = "Life">
<cfset Whatever3 = "Universe">
<cfset Whatever4 = "Everything">

<!--- This is better (Should be Faster) --->
<cfscript>
Whatever1 = 42;
Whatever2 = "Life";
Whatever3 = "Universe";
Whatever4 = "Everything";
</cfscript>


<!--- This is when you'd use SetVariable --->
<!--- This sets all the variables named above to 42. --->
<Cfloop from="1" to="4" index="i">
        <cfset temp = SetVariable("Whatever#i#", 42)>
</cfloop>

<!--- This is a better way for SetVariable --->
<!--- (At least in this silly case) --->
<cfscript>
/* C++ is my language of choice, so I just LOVE
 CFSCRIPT.  And the fact that the CFML parser
 is faster on CFSCRIPT stuff makes it even
 nicer!!!
*/
for(i=1;i LT 5;i=i+1) {
        SetVariable("Whatever#i#", 42);
}
</cfscript>

Hope that clarifies.  Basically, you should use CFSET or script
blocks 99% of the time.  When you have a dynamic situation (stuff
coming from FORM submissions is a common use), then your only
solution would be SetVariable.

Best regards,
Zac Bedell

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>
Comment: Please use PGP!!!

iQA/AwUBOWs88graVoMWBwRBEQLUrgCeJiubQ8o7jXgH1nMvlGXs1cyJ4RYAoJVX
at7C0hjXGTA5TpGvevb+JYct
=PQI5
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to