> -----Original Message-----
> From: Tom Chiverton [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 22, 2008 5:38 AM
> To: cf-talk
> Subject: Re: How can I make this code better?
> 
> On Monday 20 Oct 2008, Rick Faircloth wrote:
> > First, what variables need to be used in the <cfset var someVar = "">
> code
> > and why is it important to do this?
> 
> Everything that is local to the method.
> So cfquery names, the loop variables in cfloop, the cfhttp return scope
> etc.
> etc. etc.

It's an old trick, but the simplest way to do this is to create a
pseudo-scope.

At the top (or near the top) of your method add something like this:

<cfset var local = StructNew()>

You can then use "local" as a "scope name" throughout the method - any place
you'd need a local variable.  For example:

<cfset local.tempvariable = "">

<cfloop collection="#local.CurMembers#" item="local.CurMember">

If you use it regularly it'll quickly become second nature.

Jim Davis


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314211
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to