Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So now 3 ways.</p> <p>If you are using ColdFusion 9.0 or higher there is now a function named GetFunctionCalledName(). It will return what you are looking for. <a href="http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7cc222be8a31a47d-6e8b7083122cebfc8f2-8000.html" rel="nofollow noreferrer">http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS7cc222be8a31a47d-6e8b7083122cebfc8f2-8000.html</a></p> <p>OR </p> <p>Use ColdSpring and Aspect Oriented Programming (<a href="http://www.coldspringframework.org/coldspring/examples/quickstart/index.cfm?page=aop" rel="nofollow noreferrer">http://www.coldspringframework.org/coldspring/examples/quickstart/index.cfm?page=aop</a>) to handle this for you. </p> <p>OR</p> <p>Use a cfthrow to generate a stack trace that has the information for you:</p> <pre><code>&lt;cffunction name="determineFunction" output="FALSE" access="public" returntype="string" hint="" &gt; &lt;cfset var functionName ="" /&gt; &lt;cfset var i = 0 /&gt; &lt;cfset var stackTraceArray = "" /&gt; &lt;cftry&gt; &lt;cfthrow /&gt; &lt;cfcatch type="any"&gt; &lt;cfset stacktraceArray = ListToArray(Replace(cfcatch.stacktrace, "at ", " | ", "All"), "|") /&gt; &lt;!---Rip the right rows out of the stacktrace ---&gt; &lt;cfloop index ="i" to="1" from="#ArrayLen(stackTraceArray)#" step="-1"&gt; &lt;cfif not findNoCase("runFunction", stackTraceArray[i]) or FindNoCase("determineFunction", stackTraceArray[i])&gt; &lt;cfset arrayDeleteAt(stackTraceArray, i) /&gt; &lt;/cfif&gt; &lt;/cfloop&gt; &lt;!---Whittle down the string to the func name ---&gt; &lt;cfset functionName =GetToken(stacktraceArray[1], 1, ".") /&gt; &lt;cfset functionName =GetToken(functionName, 2, "$")/&gt; &lt;cfset functionName =ReplaceNoCase(functionName, "func", "", "once")/&gt; &lt;cfreturn functionName /&gt; &lt;/cfcatch&gt; &lt;/cftry&gt;&lt;/cffunction&gt; </code></pre> <p>My recommendation would be use getFunctionCalledName, or if not on CF 9 ColdSpring, as it will probably buy you some other things.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload