Someone once told me that reducing a value to a boolean check was quicker than 
an implicit one (though I don't know how that could be true, but you never 
know) so I took it upon myself to relieve my fingers of the extra typing years 
ago. In other words, I use it all the time with no ill effects.

The only time <cfif value> trips me up and produces an error is if:

- the variable doesn't exist
- the value is empty
- the value isn't something that could remotely be construed either as a y/n 
question or a numeric

And this generally happens during development.

Safeguards could be:

<cfif isdefined(value) and ....>
<cfif val(value)>
<cfif yesNoFormat(value)>
<cfif len(trim(value)) and value>

My 2c.

Mik


At 09:46 AM 3/14/2007, Peterson, Chris wrote:
> Peep this (inherited) code a second:
>
>    <cfif chkRegular AND chkProxy>
>      <cfset chkPrevious = "TRUE">
>    <cfelse>
>      <cfthrow>
>    </cfif>
>
>Now, I see above where, in a big next of if else then loops, chkRegular
>and chkProxy could be assigned as a string "TRUE" or "FALSE".  I guess I
>have 2 questions on this.  Is it reliable to do <cfif varName> where the
>variable is a text string and not a boolean value?  Also, what would
>happen to this code if chkRegular did not exist, would the else
>statement run, or would an error be generated?
>
>Personally, I always do <cfif varName is True>, or evaluate against a
>string in this case <cfif varName eq 'TRUE'>
>
>Just looking for opinions. =)
>
>Chris
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272650
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