My initial concern was one of aesthetics. With 18+ different variable scopes
to dump, mixing not structisempty() and structcount() just looked messy.
After further review and comments here, I see that I should err on the side
of proper functions for the proper function rather than having things look
nice. Using the logic of "if a structure has 1 or more keys" means that ALL
of the keys have to be counted before the comparison. For small structures
this may not be a problem but I've seen people who's code have HUGE
structures. Theoretically, structisempty() simply checks if there's at least
1 key in a structure and returns that information rather than counting each
key.

This is a fragment of what I'm doing:
<cfif bitmaskread(arguments.errordisplayvars, 9, 1) and not
structisempty(form)>
    <CFDUmp var="#form#" label="form"><br>
</cfif>

<cfif bitmaskread(arguments.errordisplayvars, 10, 1) and
structcount(request) gt 1>
    <!--- check the request only if there is more than 1 item in it. The
first item is cfdumpinited --->
    <CFDUmp var="#request#" label="request"><br>
</cfif>

<cfif bitmaskread(arguments.errordisplayvars, 11, 1) and not
structisempty(client)>
    <CFDUmp var="#client#" label="Client variables"><br>
</cfif>

The onError() method in my application.cfc can show different layers of
information based on where it's called from and how. My end goal is to have
an application.cfc based methodology for my apps which will control layout,
template load, ses urls (real ones) and other features. It's looking nice.

On 10/16/07, Barney Boisvert <[EMAIL PROTECTED]> wrote:
>
> structCount(url) GT 0  <----
>     or
> NOT structIsEmpty(url)
>
> Relying on CF's implicit type conversion is generally a bad idea,
> particularly when you're dealing with boolean values.  There are just
> way too many weirdnesses lurking in the shadows with boolean
> conversions.
>
> Of the two, I'd prefer the latter, since you don't care about the
> actual count, just whether it's empty or not.
>
> cheers,
> barneyb
>
>
> On 10/16/07, Michael Dinowitz <[EMAIL PROTECTED]> wrote:
> > Is there any consensus in the community as to which to use when checking
> if a structure has content or not? I'm building a killer onError() handler
> and I need to remove structures that have no content. I'm leaning towards
> structcount() as I can do
> > <cfif structcount(url)>
> > rather than
> > <cfif not structisempty(url)>
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291234
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to