RE: Function parameter question
I assume you are talking about UDFs, right? If you are writing a script based UDF, you simply exclude the optional args from your list of args in your UDF declaration. So, if function foo takes one required arg and one optional arg, the optional arg must be the second arg and you check for it's existence in your code: function foo(x) { var y = 0; if(arrayLen(arguments) gte 2) y = arguments[2]; } If you use the CFFUNCTION tag, it's as simple as saying REQUIRED="false" in your tag. === Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email: [EMAIL PROTECTED] WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda > -Original Message- > From: Robert Everland [mailto:[EMAIL PROTECTED]] > Sent: Monday, February 03, 2003 1:05 PM > To: CF-Talk > Subject: Function parameter question > > > Can I make certain parameters optional? If so how? > > Robert Everland III > Web Developer Extraordinaire > Dixon Ticonderoga Company > http://www.dixonusa.com > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Function parameter question
If you don't specify them, they still exist in the arguments scope.. i.e. Function foo() { return arraylen(arguments); } Foo() should = 0 Foo(bar) should = 1 And to access them in the funtion just called them by usual structure notation HTH -Original Message- From: Robert Everland [mailto:[EMAIL PROTECTED]] Sent: Monday, February 3, 2003 19:05 To: CF-Talk Subject: Function parameter question Can I make certain parameters optional? If so how? Robert Everland III Web Developer Extraordinaire Dixon Ticonderoga Company http://www.dixonusa.com ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Function parameter question
Every cfargument item has a "required" (true/false) property ... it is important that this only works within coldfusion - if you call the function as a webservice, the parameter has to be supplied (is always required). Best regards, Peter Orginale Nachricht Von: Robert Everland <[EMAIL PROTECTED]> Betreff: Function parameter question Datum/Zeit: Montag, 03. Februar 2003 20:22:42 > Can I make certain parameters optional? If so how? > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Function parameter question
I was talking more along the lines of CF 5. Sorry for the confusion. Robert Everland III Web Developer Extraordinaire Dixon Ticonderoga Company http://www.dixonusa.com -Original Message- From: Peter Mayer [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 2:26 PM To: CF-Talk Subject: Re: Function parameter question Every cfargument item has a "required" (true/false) property ... it is important that this only works within coldfusion - if you call the function as a webservice, the parameter has to be supplied (is always required). Best regards, Peter Orginale Nachricht Von: Robert Everland <[EMAIL PROTECTED]> Betreff: Function parameter question Datum/Zeit: Montag, 03. Februar 2003 20:22:42 > Can I make certain parameters optional? If so how? > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4