Need help with CF component call, please
Hi!
I've been working with component lately but still learning. In one of my logic I need to use an existing component and I'm not sure how to correctly call the function and get the return result from that.
Can anyone help me please?
Basically I created a component:
<cfcomponent displayname="X">
<CFFUNCTION name="GetNames">
<fargument name="1" type="String" required="TRUE">
<cfargument name="2" type="String" required="TRUE">
<!---- I do my work here ---->
within my logic, I need to call an existing function located at
in a different component And I need to use the result returned by this function.
(see below)
I'm not sure how to correctly call that function from here
Can I simply do:
<cfinvoke component="the location of Y component" method="Compare" MyVar = "MyNames" Returnresult="Z">
<CFIF #Z# NEQ 0>
<!--- DO something --->
<CFELSE>
<!--- do something else --->
</CFIF>
</CFFUNCTION>
</cfcomponent>
This is the existing componen that I need to use. It's located at the same directory:
<cfcomponent displayname="Y">
<!--- assuming this is the function that I need to call --->
<CFFUNCTION name="Compare" hint="verify names">
<cfargument name="MyVar" type="String" required="TRUE">
<cfscript>
some logic here
.......................
return return_struct;
</cfscript>
</CFFUNCTION>
</cfcomponent>
Please advice, thank you!
