[thelist] ColdFusion MX and CFIF notation
Ben Dyer
ben_dyer at imaginuity.com
Wed Nov 20 15:57:01 CST 2002
Maybe I should explain myself better.
I have always written code like so:
<CFIF query.RecordCount>
<CFOUTPUT QUERY="query">
#whatever#
</CFOUTPUT>
<CFELSE>
<p>There are no records for this query.</p>
</CFIF>
Under ColdFusion 5, if there were no records (query.RecordCount IS 0),
<CFIF query.RecordCount> would return false. If there were any records
(query.RecordCount NEQ 0), <CFIF query.RecordCount> would return true,
outputting the values.
Under ColdFusion MX, no matter what query.RecordCount is: 0, 1, 42, 20
billion, <CFIF query.RecordCount> always returns true as long as the query
is called.
And I know shorthand is (usually) bad, but I've been able to use this
method in conditional processing in basically every language I've ever used
and I'm just not sure why "Mallairia" :) took it out for MX.
Anyway, another example, using JavaScript. This works:
if (document.forms[0].fieldName.value) {
// Returns True
} else {
// Returns False
}
...so that I don't have to write "if (document.forms[0].fieldName.value !=
'')".
Listen to me, I've become a curmudgeon at the ripe old age of 23...
--Ben
At 03:33 PM 11/20/2002, Buffington, Michael wrote:
>It should still work. I just tested it on my single developer version of
>MX and it works fine.
>
>I know you didn't ask for opinion on this, but I can't resist; my personal
>preference is to use "longhand" for things like this, for a couple of
>reasons: code readablity, and the fact that some less experienced
>developers get confused about this (I know, shameful, but true).
>
>By the way, are you getting a specific error, or is it just evaluating to
>false? Could be that there are indeed no records in the "Whatever" query.
More information about the thelist
mailing list