when you omit the comparison operator (EQ, NEQ, IS, GT,...) the IF statement
assumes the value is boolean.  If the value you are testing is not numeric
it will err.  If it is numeric then 0 is FALSE and anything > 0 is TRUE.  

For example:

<cfif query.recordcount>
        this will display if any records were returned
</cfif>

<cfif len(string)>
        this will display if the string is at least one character long
</cfif>

<cfif string>
        this will display if string is a numeric value GT 0
</cfif>
*** the above example will err if STRING cannot be converted to a number.


+-----------------------------------------------+
Bryan Love
  Macromedia Certified Professional
  Internet Application Developer
  Database Analyst
Telecomunication Systems
[EMAIL PROTECTED]
+-----------------------------------------------+

"...'If there must be trouble, let it be in my day, that my child may have
peace'..."
        - Thomas Paine, The American Crisis



-----Original Message-----
From: Jon Hall [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 29, 2001 4:40 PM
To: CF-Talk
Subject: cfif shorthand


I'm working on some code that uses a shorthand (I guess...) cfif style quite
a bit. I have tried to stay away from doing this since it makes the code
harder to read, so I never really took the time to figure it out.

For instance...
<cfif query.recordCount>
Is this testing for the existence of the query or if it is greater than
zero?

<cfif len(query.date)>
This particular one has me scratching my head, it never seems to test
negative in the code, but what is it testing for?

Could someone please fill me in here...

jon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to