Thanks, this is actually beginning to make some sense. As to the variables.A throwing an error, I figured out that I wasn't being consistent in my naming. I set it as variables.A, but then I called it in the calculation as just A. When I changed that call to variables.A everything worked/didn't work just as described. Reinforcing that the variables scope and the un-named scope are completely different and don't share information.
-------------- Ian Skinner Web Programmer BloodSource Sacramento, CA -----Original Message----- From: Michael Tangorre [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 11:57 AM To: CF-Talk Subject: Re: CFC Newbie Discussion. You are asking all the right quesitons to learn... keep asking. :-) to keep variables protected within functions, use: <cfset var myvariable = something> to keep variables protected to the cfc and functions within the cfc, use: your own structure or use no scope. <cfset myvariable = something> to allow variables to be exposed to the cfc (including the functions) as well as the calling templates, use: <cfset this.myvariable = something> In terms of the variables scope you get an error on, to be honost, I do not know. I do not use the variables scope within CFCs. Id be interested to know though. Hope this helps you. Mike ----- Original Message ----- From: "Ian Skinner" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Tuesday, June 10, 2003 2:49 PM 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 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 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4