Simon Horwith wrote:
But either way, isn't that what Steve just said??correction... I just tried the code and it's taking about 1/30 the amount of time to use java... which is still VERY significant.
Duncan, I think both of those articles refer to CF5. I'm not sure, but I think that its not entirely relevant to CFMX.
Anyway, the reason it takes "twice as long" is because the condition and _both_ outcomes have to be interpreted before run time, so IIF shouldn't be used in a situation where you expect any part of either of the conditions to not exist.
In terms of the readability comments that people always make about IIF() : I've seen plenty of <cfif> statements that are a complete mess and far less readable than a single IIF statement would have been. Part of the reason is because the <cfif> is being used to alter html tags, where a nice inline or immediate IF makes the HTML and the condition readable.
In Karl's case, I suspect I would probably write a bit of code outside the html eg.
<cfscript>
if (GetPatients.wait_time_mins[i] GT 381000) BGColour = 'red';
else if (GetPatients.wait_time_mins[i] GT 375000) BGColour = 'orange';
else BGColour = 'blue';
</cfscript>
<td style="background-color:#BGColour#">
But if I just had to outcomes blue or orange say I'd use the IIF() eg. IIf(GetPatients.wait_time_mins[i] GT 375000, DE('orange'), DE('blue'))
This will not take any longer to process than a <cfif> and the code is infinately more readable than if I were to include a <cfif
Even Karl's double IIF isn't going to take any longer or shorter to process than a <cfif> None of the outcomes have anything to process....
As with everything in life, there is a time and a place for IIF()... ~shrug~
Stephen
-- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
