As a caveat, I don't think it will get outside variables in the variables scope unless you call it from outside the cfc, of course. But, you may find a neat way around that.

Sammy Larbi wrote, On 12/8/2006 11:31 AM:
Actually, this is quite a bit easier that I thought. This function will output the names of all the variables (I think) that reference your component, given a scope. I got the idea for inserting a UUID from looking at cfcUnit, so I gotta give credit there. Of course, it will need to be in your component.

<cffunction name="getTheNameOfTheVariableThatContainsMe" output="true">
       <cfargument name="variablesScope" required="true">
       <cfset this.testkey = createUUID()>
       <cfloop list="#structkeylist(variablesScope)#" index="name">
<cfif isStruct(variablesScope[name]) and structKeyExists(variablesScope[name],"testKey") and variablesScope[name].testKey eq this.testKey>
               #name#,
           </cfif>
       </cfloop>
       <cfset structDelete(this,"testKey")>
</cffunction>




Ed Griffiths wrote, On 12/8/2006 8:40 AM:
Hi

Quick question. If you store an object in a variable like this:

<cfset myObject = createObject("component","testObject").init()>

Is it possible to interrogate some method or metadata associated with
testObject in order to find out what variable name it has been stored within
(myObject in this case)?

Thanks for your help,
Ed




You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

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






You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

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






You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

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

Reply via email to