OK this all makes a little more sense......
1 question I have is why are you guys defining coreLV like this
<cfset var coreLV = "">
I am just trying to make sure I am on the same page with everyone.  coreLV is a constant that is set on another page before it enters my cfc
 
 
thanks for all your help
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Nando
Sent: Friday, March 10, 2006 8:54 AM
To: [email protected]
Subject: Re: [CFCDev] cfc scope issues

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:
  
I am new to cfc's and was working on trying to convert some of my custom
tags to cfc's. The one problem I come across is trying to use the caller
scope.
 In my custom Tag which is below I did this by:

<cfoutput query="coreLV">
         <cfset "caller.C_#listchangedelims(
listchangedelims(listchangedelims(coreLV.legalValue,'_','-'),'_','
'),'_','/')#" = coreLV.lKey>
 </cfoutput>

 basically this just loops through a query and set up a bunch of constantsto
be used on any cfm page.
 Now i would like to do the same in a cfc but cant get this to work. This is
what i have come up with so far..... Please Help

 <CFFUNCTION NAME="createCoreConstants" access="remote" returntype="void">
 <CFARGUMENT NAME="tablename" type="string" required="yes">
         <cfquery name="coreLV" datasource="#request.app.DSN#"
blockfactor="10" cachedwithin="#request.app.queryCache30#">
                 SELECT
dbo.#ARGUMENTS.tableName#.legalValue,
dbo.#ARGUMENTS.tableName#.lKey
                 FROM dbo.#ARGUMENTS.tableName#
                 where dbo.#ARGUMENTS.tableName#.isActive=1
         </cfquery>
         <cfoutput query="coreLV">
                 <cfset "CALLER.C_#listchangedelims(
listchangedelims(listchangedelims(coreLV.legalValue,'_','-'),'_','
'),'_','/')#" = coreLV.lKey>
         </cfoutput>
 </CFFUNCTION>

Basically in the end I would like to execute a cfc that will loop through a
table and create constants for
each record in the table that are available to be accessed on any page

Thanks for you Help in advance
Ryan Hamoud
----------------------------------------------------------
 You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.

 CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).

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


--
Charlie Griefer

================================================
"...All the world shall be your enemy, Prince with a Thousand Enemies,
and whenever they catch you, they will kill you. But first they must catch
you, digger, listener, runner, prince with a swift warning.
Be cunning and full of tricks and your people shall never be destroyed."


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.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' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

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


.

  


--


Aria Media Sagl
CP 234
6934 Bioggio
Switzerland
www.aria-media.com


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

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

Reply via email to