Use a return variable inside of a function in another function

How to I use a variable that collected data inside of a function and call that variable into a another function?

So if I have a variable thats called "age" inside of a function and I want to create another function thats adds to it.  How would I go about doing that?
Who is Participating?
SidFishesConnect With a Mentor Commented:
You can call a function from a function

(don't forget to change the name to the name your component)
<cfcomponent name="TestCFC">
<cffunction name="getNewAge" returntype="numeric">
	<cfargument name="age" required="true">
	<cfinvoke component="testCFC"  method="addAge" returnvariable = "newAge">
		<cfinvokeargument name="age" value="#arguments.age#">
<cfreturn NewAge>
<cffunction name="addAge" returntype="numeric">
	<cfargument name="age" required="true">
		<cfset NewAge = arguments.age +1>
	<cfreturn NewAge>
then on your calling page
<cfinvoke component="com.testCFC"  method="getNewAge"  returnvariable = "newAge">
	<cfinvokeargument name="age" value="1">
<cfoutput>New Age IS:  #newAge#</cfoutput>

Open in new window

All Courses

From novice to tech pro — start learning today.