One question that's always asked is
"Where is this function being used?".
A simple search can find that. But the next question is always:
"How often?"
You could say
"Well, this page uses it x amount of times, and this other page uses it
y."
Original 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)?
Sammy Larbi's answer:
<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>
________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dave Shuck
Sent: Wednesday, December 13, 2006 7:17 PM
To: [email protected]
Subject: Re: [CFCDEV] Does a CFC know what variable name it's stored
within?
Beat me to it! I was scratching my head on that one too. From a bigger
picture perspective, what are you trying to accomplish Ed?
~d
On 12/13/06, Andrew Scott <[EMAIL PROTECTED]> wrote:
I am curious to know why one would want to know this information though?
Andrew Scott
Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613 8676 4223
Mobile: 0404 998 273
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On
Behalf
Of Ed Griffiths
Sent: Wednesday, 13 December 2006 11:57 PM
To: [email protected]
Subject: RE: [CFCDEV] Does a CFC know what variable name it's stored
within?
Hi
Thank you to everyone who replied about this issue.
Cheers
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]
--
~Dave Shuck
[EMAIL PROTECTED]
www.daveshuck.com
Where's your Spot?
www.instantspot.com
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]