In order to use optional UDF parameters, you must not specify them in
the function declaration. See below:
function sayHello(first) {
var last = "";
if(arrayLen(arguments) gte 2) last = " " & arguments[2];
return "Hello, " & first & last;
}
Notice I changed your writeOutput to a return. You should always return
something in a UDF.
=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia
Email : [EMAIL PROTECTED]
Yahoo IM : morpheus
"My ally is the Force, and a powerful ally it is." - Yoda
> -----Original Message-----
> From: Jamie Jackson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 29, 2002 10:59 AM
> To: CF-Talk
> Subject: Optional UDF arguments
>
>
> Is it possible to have optional UDF arguments (such as "last" in the
> following example)?
>
> AFAIK, this doesn't work.
> function sayHello (first, last) {
> if (notisdefined('last')) {var last = '';}
> writeoutput('Hello, ' & first & ' ' & last);
> }
>
> Thanks,
>
______________________________________________________________________
Why Share?
Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
Instant Activation � $99/Month � Free Setup
http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists