I thought that an earlier thread had concluded that best practice was to use

this.                   public class variables
instance.               private class variables
var VariableName        for private function variables

Andy

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Darcey Spears
Sent: Wednesday, December 17, 2003 12:10 PM
To: [EMAIL PROTECTED]
Subject: [CFCDev] "Variables" scope....tearing out hair


Hi,
Trying to figure out what I'm doing wrong here.....I'm using this example
from Sean's CF Coding Standards:

<cfcomponent>

     <cffunction name="example">
         <cfset var localVar = "Just in this function" />
         <cfset variables.nonPublicVar = "Non-public data member" />
         <cfset anotherNonPublicVar = "Not recommended - use 'variables'" />
         <cfset this.publicVar = "Public data member" />
     </cffunction>

     <cffunction name="more">
         <cfset var localVar = "Different to example localVar" />
         <cfset var x = variables.nonPublicVar & " set in 'example' above"
/>
     </cffunction>

</cfcomponent>

Display CFM page has:

<cfobject name="someVarTest"
component="wherestom_working.dirPackage.standards_var_example">

<cfinvoke
  component="#someVarTest#"
  method="more">
</cfinvoke>

I've also tried just a direct invocation of the "more" method:
<cfinvoke
  component="wherestom_working.dirPackage.standards_var_example"
  method="more">
</cfinvoke>

and no matter what I do with variables.nonPublicVar it just doesn't seem to
be defined or available outside the method where it's created. I get an
error saying "nonPublicVar is not defined in Variables" every time I try to
use it.

I'm running CFMX 6.1 on Windows XP with the default installation.

I must be doing something wrong....but what??? My understanding is that
"variables" scope variables are available to all methods in the component
in which they are defined.

Thanks for any help you can provide to keep my hair actually attached to my
head... =:0
Darcey



Darcey Spears
Q3Studios Collaborative Web Development
www.q3studios.com
520-360-5425


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to