This is due to a known bug. In general, just leave off Variables, or,
use your own struct:

<cfset local = structNew()>
<cfset local.a = "jedi">

By the way, there is one more scope you should be convered with - and
that is 'var' scoped method variables. Whenever you use a value in a
method, a value that is NOT meant to exist in the CFC whole, you should
use the var scope. Here is an example:

<cffunction name="getCrap" .....>
        <cfargument name="id" ....>
        <cfset var myQuery = "">

        <cfquery name="myQuery" ...>
        ...
        </cfqyery>

        <cfreturn myQuery>

</cffunction>

ANY variable created inside a method should be var scoped (unless you
want it to exists outside the method). Don't forget things like
<cfquery> create values, ditto for cfdirectory, etc.


========================================================================
===
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
(www.mindseye.com)
Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)

Email    : [EMAIL PROTECTED]
Blog     : www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus

"My ally is the Force, and a powerful ally it is." - Yoda 

> -----Original Message-----
> From: Ian Skinner [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 10, 2003 12:49 PM
> To: CF-Talk
> Subject: RE: CFC Newbie Discussion.
> 
> 
> Ahh, I understand now, the best practice we are talking about 
> is protecting the state/variables of ones objects, but using 
> private variables and functions to manipulate them.  I would 
> generally agree with that as well, for a little as I've used 
> objects in programming to date.  I'm just trying to get as 
> complete a picture of how each scope and access behaves so I 
> can better know how to write code that will do what I want it 
> and how to debug it when it doesn't.
> 
> 
> A question on the "variables" scope bug in a CFC.  The link 
> provided earlier stated that a variable defined in a CFC 
> using the variables scope would be accessible to the methods 
> of the component (proper) as well as the calling template 
> (improper/bug).  But in my experiments I found the variables 
> I scoped with "variables" where ONLY accessible to the 
> calling template and not any of the methods in the CFC.  Is 
> this bug bigger then I understand, or is something else going on here?
> 
> Example
> <cfcomponent>
>       <cfset Variables.A = 7>
>       <cfset Variables.B = 11>
> 
>       <cffunction name="multiplyAB1" access="public" 
> returntype="numeric">
>               <cfset myResult = A * B>
>               <cfreturn myResult>
>       </cffunction>
> </cfcomponent>
> 
> In this example, I get an error stating that the variable A 
> is not defined?
> 
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> Sacramento, CA
> 
> 
> -----Original Message-----
> From: Christian Cantrell [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 10, 2003 11:40 AM
> To: CF-Talk
> Subject: Re: CFC Newbie Discussion.
> 
> 
> On Tuesday, June 10, 2003, at 02:20 PM, Raymond Camden wrote:
> 
> > While I strongly urge folks to not use the This scope, I 
> would _not_ 
> > call it a bug. The This scope works _exactly_ as 
> advertised, it's just 
> > not the preferred way of storing data for a CFC.
> 
> Raymond is correct.  It is not a bug -- it's just how CFCs were 
> designed to work.  If you need data publicly accessible, use of the 
> "this" scope is fine.  If you need your data to be private, 
> either use 
> the "unnamed" scope, or create your own private struct.  I would 
> recommend keeping data as private as possible, however if you don't 
> feel you need to, or it doesn't fit with your architecture, then do 
> what is best for you.
> 
> Christian
> 
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Get the mailserver that powers this list at 
http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to