Roland Collins said the following on 3/2/2006 5:16 PM:
I never use YesNoFormat() - I was running out the door and didn't take the time to write the best reply (should have just let others do it). I used it for understandability.It's subtle, but values that return integers should always be tested against other integers. It's (mildly) bad form to rely on the fact that CF evaluates 0 as false, especially considering that when you think about it, what you're really writing is "0 is false". Implicit conversion or no, doesn't that look odd?null="#Len(form.CustNo) is 0#" is really what you you're trying to test. Also, the YesNoFormat is unnecessary, since all that does is return a string containing "yes" or "no". These are then also implicitly converted into their boolean equivalents. Roland I don't really think it's bad form per se IMHO. I understand that NOT Len(..) uses negative logic and that it can be cumbersome for some. I only use it in certain situations and that it might not be best to rely on implicit conversions. In my defense, CF does not have to make a comparison with an operator (like Len(...) EQ 0 when using negative logic which supposedly would save some cycles over a period of time. CF resolves 0 to false and anything else as true -- I doubt this will change since the language is typeless. No sense in testing a boolean with another boolean -- like boolExpr IS true or boolExpr IS false. You may want to use a UDF in this case to encapsulate your logic: <cffunction name="isNull" access="public" returntype="boolean" output="false"> <cfargument name="value" type="string" required="true" /> <cfreturn NOT len(arguments.value)> </cffunction> If my source is correct, these are the implicit conversions for the following languages. Taken from http://www.hal-pc.org/~clyndes/computer-arithmetic/calculations.html
I recall this exact conversation last July (2005) with Bill Rawlinson and you (Roland). So all in all, it really comes down to personal preference is your coding style. In my mind, NOT Len(...) equates to "I want FALSE" to execute this next block of code in my mind. Anyways, all the other suggestion are way better than using Len(...) EQ "" IMHO. That's that and I don't want to sound like I'm want to argue about it, just sort thinking out loud here. Best, .Peter -- Peter J. Farrell :: Maestro Publishing Member Team Mach-II :: Member Team Fusion http://blog.maestropublishing.com Create boilerplate beans and transfer objects for ColdFusion! Fire up a cup of Rooibos! http://rooibos.maestropublishing.com/---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected] |
- Re: [CFCDev] CSV and blank lines Daniel Roberts
- Re: [CFCDev] CSV and blank lines Jon Gunnip
- Re: [CFCDev] CSV and blank lines Bill Rawlinson
- RE: [CFCDev] CSV and blank lines Jamie Tieman
- Re: [CFCDev] CSV and blank lines Chris Stoner
- Re: [CFCDev] CSV and blank lines Chris Stoner
- [CFCDev] OT: Empty fields passed as integer paramet... Phillip Senn
- RE: [CFCDev] OT: Empty fields passed as integer... Cody Caughlan
- Re: [CFCDev] OT: Empty fields passed as integer... Peter J. Farrell
- RE: [CFCDev] OT: Empty fields passed as int... Roland Collins
- Re: [CFCDev] OT: Empty fields passed as... Peter J. Farrell
- RE: [CFCDev] OT: Empty fields pass... Phillip Senn
- Re: [CFCDev] OT: Empty fields passed as integer... CF
- Re: [CFCDev] CSV and blank lines jason . r . cronk
- RE: [CFCDev] CSV and blank lines Cody Caughlan
- RE: [CFCDev] CSV and blank lines Shepherd, Brandon
- RE: [CFCDev] CSV and blank lines jason . r . cronk
- RE: [CFCDev] CSV and blank lines Jamie Tieman
