Hi Bec

Give this a go:


<cfset objScribble = createObject("component","scribble") >

<cfoutput>#objScribble.fDynamic('helloworld2')#</cfoutput>

<cfcomponent >

        <cffunction name="fDynamic" returntype="string">
                        <cfargument name="fName">

<!--- note how i put it into a variable first ---> <cfset myFunct = this[Arguments.fName] >

                        <cfreturn myFunct() >
        </cffunction>

        <cffunction name="helloWorld1" returntype="string">
                <cfreturn "hello world 1">
        </cffunction>
        
        <cffunction name="helloWorld2" returntype="string">
                <cfreturn "hello world 2" >
        </cffunction>

</cfcomponent>

Cheers

Pat


Bec Gorton wrote:
Hey all.
Does anyone know how i can dynamically call functions from within a
component?

For example, i want to be able to do something like:

<cfset function_name = "myFunction">
<cfset this[function_name]()>

This should be the same as if i called <cfset this.myFunction()>

This is not the right syntax, does anyone know what the correct syntax is?
I'm sure i could use an eval, but i'm of the opinion that eval is a bit
fugly.

Cheer bec.





---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to