On 1/27/06, Oleg Gunkin <[EMAIL PROTECTED]> wrote:
> How do I make a function with unlimited number of parameters, and how do I
> access these parameters?
<cffunction name="foo">
<cfset var i = 0>
<cfset var n = arraylen(arguments)>
<cfloop from="1" to="#n#" index="i">
<cfoutput><p>#arguments[i]#</p></cfoutput>
</cfloop>
</cffunction>
<cfscript>
foo();
foo(1,2,3);
</cfscript>
You can access arguments as an array or as a struct (if you dump it
inside foo() you'll see a struct - with no keys for the first call and
with three keys for the second: "1", "2" and "3").
--
Sean A Corfield -- http://corfield.org/
Got frameworks?
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:230653
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54