|
If you need access to a variable that's set on the page (or a
structure, array, query, etc) the way to do that would be to pass them
into the function in the CFC, just like you are passing in the
tablename as an argument. If you need access to a variable after it's
been processed by the CFC's function, the way to do that would be to
return it using the cfreturn tag at the bottom of the function. Not 100% sure because i don't understand the context of what you're trying to do, but i think it should look more like this: <CFFUNCTION NAME="createCoreConstants" access="remote"> <!--- pass all your variables into your functions ---> <cfargument name="DSN" type="string" required="yes"> <cfargument name="tablename" type="string" required="yes"> <cfargument name="queryCache30" required="yes"> <!--- var scope all variables local to the function - important ---> <!--- name of all queries or iterators, etc are var scoped ---> <cfset var coreLV = ""> <cfset var valueToReturn = ""> <!--- variables needed in the query are referenced from within the encapsulated variable space of the CFC or function ---> <cfquery name="coreLV" datasource="#arguments.DSN#" blockfactor="10" cachedwithin="#arguments.queryCache30#"> SELECT dbo.#ARGUMENTS.tableName#.legalValue, dbo.#ARGUMENTS.tableName#.lKey FROM dbo.#ARGUMENTS.tableName# where dbo.#ARGUMENTS.tableName#.isActive=1 </cfquery> <!--- i know this isn't what you were doing exactly, but just to give an example how a value can be returned to the page (or another CFC) calling this function ---> <cfset valueToReturn = listchangedelims( listchangedelims(listchangedelims(coreLV.legalValue,'_','-'),'_',' '),'_','/') > <cfreturn valueToReturn /> </CFFUNCTION> CFC's behave more or less like objects by design, which means their variable space is encapsulated. There are distinct advantages to encapsulation, there really are, but it's bit of a paradigm shift from the "all variables are available" world of a procedurally coded CFM page. Encapsulation forces you to think about application design. And if someone hasn't learned the art of OO design, encapsulation can seem much more like a barrier than an advantage. Not sure how familiar you are with OO principles, (and i'll take the liberty of assuming you don't know much about it for the rest of this post, forgive me if i've got that wrong) but if you haven't studied OO much, you might want to head in that direction to understand how to get the most out of CFCs. It's not really necessary, you can use them as simple function libraries, similar to how we've used UDF's in the past. But to get the most power out of them, or even to understand what most people are talking about on this list most of the time, understanding OO is a must. Ask if you'd like some suggestions for OO books to read. HTH, Nando Hamoud, Ryan N. wrote: So is not possible to accomplish this with a CFC? When i did this with my custom tage i was able to access allmy constants on any page as follows.....example <cfset tablename = #C_LV#> I would still like to be able to do this.-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Charlie Griefer Sent: Thursday, March 09, 2006 3:31 PM To: [email protected] Subject: Re: [CFCDev] cfc scope issues Ryan - a quick primer on scopes and CFCs: http://ray.camdenfamily.com/downloads/cfcscopes.pdf On 3/9/06, Hamoud, Ryan N. <[EMAIL PROTECTED]> wrote: |
- [CFCDev] cfc scope issues Hamoud, Ryan N.
- Re: [CFCDev] cfc scope issues Charlie Griefer
- [CFCDev] New IE broswer "Activate ActiveX C... Ung, Seng
- Re: [CFCDev] New IE broswer "Activate A... Daniel Roberts
- RE: [CFCDev] New IE broswer "Activa... Ung, Seng
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- Re: [CFCDev] cfc scope issues Daniel Roberts
- Re: [CFCDev] cfc scope issues Matt Woodward
- Re: [CFCDev] cfc scope issues Nando
- RE: [CFCDev] cfc scope issues Phillip Senn
- Re: [CFCDev] cfc scope issues Patrick Lebon
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Hamoud, Ryan N.
- RE: [CFCDev] cfc scope issues Jean Moniatte
- Re: [CFCDev] cfc scope issues Peter J. Farrell
- RE: [CFCDev] cfc scope issues Phillip Senn

