> It looks to me like the variables passed by reference (using the
> byref keyword) are used for return variables. If I also remember
> correctly, CF UDFs only allow a single return value by default.
Yes, you may only return one thing from a function.
> Is there a way to pass variables into a CF UDF by reference?
Yes, although not explicitly. In CFML, queries, structures, and object
references are passed by reference, while arrays and simple values are
passed by value.
If you want to explicitly pass something by reference, you have to convert
it into a query, structure, or an object.
<cfset mystruct = StructNew()>
<cfset mystruct.myval = "foo">
<cffunction name="example">
<cfargument name="stData">
<cfset Arguments.stData.myval = "bar">
<cfreturn>
</cffunction>
<cfset example(mystruct)>
<!--- will output "bar" --->
<cfoutput>#mystruct.myval#</cfoutput>
The idea of placing a value type within an object so that it will be passed
by reference is generally referred to as "boxing", if I recall correctly.
> Based upon the supposition that this is used for return
> variables, is it even needed?
Probably not, although I have no idea without seeing the original code.
> Can I use the CALLER scope to return multiple variables from
> the UDF?
No, the Caller scope only works within a custom tag, to the best of my
knowledge. Actually, I haven't tested this, though.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:243033
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54