macromedia.coldfusion.advanced_techniques
[Top] [All Lists]

Re: Callback function in CF?

Subject: Re: Callback function in CF?
From: Adam Cameron
Date: Mon, 22 Sep 2008 19:23:34 +0100
Newsgroups: macromedia.coldfusion.advanced_techniques

>  Is there a way to pass a function pointer?

>  <cffunction name="func">
>       <cfargument name="arg1" type"string">
>       <cfoutput>#Evaluate(arg1)#</cfoutput>
>  </cffunction>
> 
>  <cffunction name="callback_func">
>       in callback function
>  </cffunction>
> 
>  <cfoutput>
>       #func("callback_func()")#<br>
>  </cfoutput>

Don't pass the function's name it, pass the function itself in:

{code}
<cffunction name="func">
        <cfargument name="arg1" type="any"><!--- not really "any" but nothing 
more
appropriate to choose from --->
        <cfoutput>#arguments.arg1()#</cfoutput>
</cffunction>

<cffunction name="callback_func">
        in callback function
</cffunction>

<cfoutput>
        #func(arg1=callback_func)#<br>
</cfoutput>

{code}

-- 
Adam

<Prev in Thread] Current Thread [Next in Thread>