> One function came to mind and that was IsEmpty(). Simply put it, checks 
> to see if a variable is Empty yes/no.

So would this return TRUE in - for example - these data types and
equivalent states:
string/simple - empty string
struct - no keys defined (equiv of structNew())
array - no elements defined (equiv of arrayNew(i))
query - maybe columns, but no rows defined (equiv of queryNew(s))
xml - no root element defined 
(any others?)

but automatically determine which check to make, having detected the
data-type?  Interesting.  Can't say I've ever needed a generic function to
do this, but maybe YMMV.

> In that, <cfif arguments.IsEmpty()> or <cfif myVar.isEmpty()>

Depends.  All other "official" CF functions are of the form
IsEmpty(arguments)
ToString() doesn't count, as that's using an underlying Java method, not a
CF function, and is not supported (or encouraged) by Macromedia.  Hey: I
use them all the time myself, though.  I would not start suggesting that
syntax merely on the basis of that, though.

However, a good reason to do it is that then there could be a generic
isEmpty() method of WEB-INF.cftags.component, which means it could be used
reliably on CFC instances too (provided you overload the method to make it
meaningful).  That means a homogeneous way of testing emptiness.
 
> Now before you start.. you are aware that some variables/scopes allow 
> toString()

As stated: that's Java, not CF.

> if(len(stringvar) LTE 0)) do xyz....

Never.  Maybe:

if (not len(stringVar))

len() returns a boolean-ready value.  There's no need to do two boolean
evaluations to arrive at the same result, there.

But like I said... I've never had a situation where I don't know what type
of variable I've got, and accordingly need to have a generic isEmpty()
method.  So... I'm not so sure.

You could always submit an enhancement request, though.

Adam

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to