Yeah indeed, this is an extra level of failsafing when query.recordcount can
fail whereas a true boolean check such as IsStruct will never fail, I
suppose it is preference :-) I just done like evaluating a statement which I
know can "fail" (when using a bool check).


 






"This e-mail is from Reed Exhibitions (Gateway House, 28 The Quadrant,
Richmond, Surrey, TW9 1DN, United Kingdom), a division of Reed Business,
Registered in England, Number 678540.  It contains information which is
confidential and may also be privileged.  It is for the exclusive use of the
intended recipient(s).  If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful.  If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910.  The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions." 
Visit our website at http://www.reedexpo.com

-----Original Message-----
From: Teddy Payne
To: CF-Talk
Sent: Mon Oct 02 14:11:15 2006
Subject: Re: CFIF Statement

Evaluation on a numeric value can also be called implicit evaluation.

For those worrying about whther or not they have a valid query, why not
create a simple compound <cfif> statement that takes use short circuit
evalution?

<cfquery name=qryFoo" datasource="blah">
..... insert sql here ...
</cfquery>

<cfif isDefined("qryFoo") and qryFood.recordcount>
..... more code ...
</cfif>

Detect that the query exist first.  If the query does not exist, then the
recordcount won't evaluate because of the "and" operator.  The statement
executes from left to right.

Alternate solution would be to also say:

<cfif isDefined("qryFoo") and qryFood.recordcount gt 0>
..... more code ...
</cfif>

I believe that if the query throws an exception and you try/catch it, then
the variable is not set and that should alleviate most needs for wondering
if a recordcount will exist.

Teddy

On 10/2/06, Robertson-Ravo, Neil (RX) <[EMAIL PROTECTED]>
wrote:
>
> Erm, I never said it was ambiguous (if this is indeed the message you are
> replying to). The point is that query.recordcount is not a boolean - it
> could have 3 possible values true, false, nothing..(in ColdFusion terms)
>
> Implicit evaluation when the value is a boolean is great, if it is
> guaranteed to be one that is.
>
>
>
>
>
>
>
>
>
>
>
>
> "This e-mail is from Reed Exhibitions (Gateway House, 28 The Quadrant,
> Richmond, Surrey, TW9 1DN, United Kingdom), a division of Reed Business,
> Registered in England, Number 678540.  It contains information which is
> confidential and may also be privileged.  It is for the exclusive use of
> the
> intended recipient(s).  If you are not the intended recipient(s) please
> note
> that any form of distribution, copying or use of this communication or the
> information in it is strictly prohibited and may be unlawful.  If you have
> received this communication in error please return it to the sender or
> call
> our switchboard on +44 (0) 20 89107910.  The opinions expressed within
> this
> communication are not necessarily those expressed by Reed Exhibitions."
> Visit our website at http://www.reedexpo.com
>
> -----Original Message-----
> From: Dave Watts
> To: CF-Talk
> Sent: Mon Oct 02 02:11:33 2006
> Subject: RE: CFIF Statement
>
> > No, the point here is that <cfif query.recordcount> will give
> > you true or false usually reserved for booleans which do
> > actually give true/false/1/0, such as isStruct()....
>
> If a language supports implicit evaluation of integers as Boolean values,
> there is nothing wrong with taking advantage of it. If I suggested that
> you
> should cast strings to numbers in CF or vice-versa, you'd almost certainly
> think that was ridiculous. And, any competent CF developer is aware that
> CF
> supports this, so an argument that it's ambiguous doesn't really hold much
> weight.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
>
> Fig Leaf Software provides the highest caliber vendor-authorized
> instruction at our training centers in Washington DC, Atlanta,
> Chicago, Baltimore, Northern Virginia, or on-site at your location.
> Visit http://training.figleaf.com/ for more information!
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

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

Reply via email to