Can you have a CFC return several variables? If so, how?
As others have said, in a struct... however, your question is really about a deeper philosophical design issue, namely: return status codes or throw exceptions.
Here's the situation ... I have a CFC that validates a code, looks up some
values in a table and returns them. I want to be able to return a variable
saying "yes, it's valid" and another with the fee, another with the start
date.
How about having the method throw an exception if the code is invalid else returning a struct containing the details (fee, start date)?
Exception handling can make for much more readable code because you don't have to pepper your calling code with <cfif> checks on the status code and you also can't forget to handle the errors - your code can't 'fall through' with invalid data.
Mind you, it's also bad to overuse exceptions - if you are *expecting* an error condition (like, end of file or bogus user input), then it isn't really an exception. Exceptions are for things you don't really expect to happen (database failure, XML parsing failure... the sort of things that CF already throws exceptions for).
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive." -- Margaret Atwood
--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004
