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

Call a function within the same CFC component

Subject: Call a function within the same CFC component
From: "Philippe Forget"
Date: Fri, 17 Aug 2007 11:58:36 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
Hi,
 /* Niewbie Question */
 I've got a strange problem. When I try to call a function from another in the 
same CFC component, I get an Error named : « Entity has incorrect type for 
being called as a function.»
 I've looked on many forums and searched in Google Groups. I haven't still 
found a workaround for that problem.
 I thought I've paid attention not o use two times the same name...
 Can anyone tell me what error I made ?

 My sample code to reproduce this error is included

 The complete error message is :
  Entity has incorrect type for being called as a function.
 The symbol you provided superfunction is not the name of a function.
  
 The error occurred in C:\ColdFusion8\wwwroot\admin\_components\test.cfc: line 6

 4 :            <cfinvoke
 5 :             method = "superfunction"
 6 :             returnVariable = "myReturn">
 7 :         </cfinvoke>
 8 :         <cfset some_text = myReturn>


 <!--- Start of %root%/page.cfm --->

 <!--- Instanciate component --->
 <cfobject component="admin._components.test" name="objTest">

 <cfinvoke method="objTest.coolfunction">

 <!--- End of %root%/page.cfm --->

 <!--- Start of %root%/_components/test.cfc --->
 <cfcomponent>

        <cffunction name="coolfunction">
        <cfinvoke
             method = "superfunction"
             returnVariable = "myReturn">
         </cfinvoke>
         <cfset some_text = myReturn>
         <cfreturn some_text>
     </cffunction> 
     
     <cffunction name="superfunction">
        <cfargument name="myArg1">
         <cfargument name="myArg2">
        <cfset myVariable = myArg1&" toto "&myArg2>
         <cfreturn myVariable>
     </cffunction>
     
 </cfcomponent>

 <!--- End of %root%/_components/test.cfc --->


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