Here's an example of how I use CFIF to alternate row colors. In practice, I
use this with CFOUTPUT, but here I've used CFLOOP so the example is
stand-alone.

----------------------------------------------------------
<CFSET bgcolor = "FFFFFF">
<TABLE CELLPADDING="5" CELLSPACING="0" BORDER="0" WIDTH="600">
<CFOUTPUT>
<CFLOOP INDEX="line_num" FROM="1" TO="10">
<CFIF bgcolor IS "FFFFFF">
        <CFSET bgcolor = "E6E6E6">
<CFELSE>
        <CFSET bgcolor = "FFFFFF">
</CFIF>
<TR>
        <TD BGCOLOR="#bgcolor#">#line_num#</TD>
</TR>
</CFLOOP>
</CFOUTPUT>
</TABLE>
----------------------------------------------------------

-----Original Message-----
From: Bruce Holm [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 26, 2001 3:40 PM
To: CF-Talk
Subject: Re: IIF vs if,else


My understand, based on what an expert (seminar instructor) said was that
yes, IIF is significantly slower than using CFIF and should be avoided if
possible.  But there are cases where IIF can be used where CFIF can't.  For
example, one way of alternating the highlight background color on table rows
uses IIF within the TD tag to pick the background color... something where
CFIF can't be used.


----- Original Message -----
From: "Cameron" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, June 19, 2001 4:02 PM
Subject: IIF vs if,else


Ok, after a bit of testing... can anyone tell me what the advantage of IIF
over if (<cfif> or if () {}), else (<cfelse> or else {}).

I tested a simple block of code using IIF and <cfif><cfelse></cfif> & IIF
ran twice as slow...

I can't see any major advantage by using it... yeah, it is kinda similar to
i = (true?1 : 2); in javascript but it's really slow case of the implicit
evaluate() on each part. Would be better if it was implicit & made explicit,
IF NEEDED.

Can anyone give me a decent reason why IIF is better that <cfif>?

Cameron Junge
Web Developer
Strongnet
[EMAIL PROTECTED]
http://www.strongnet.co.nz
Ph: +64 9 414 2492
Fax: +64 9 414 2960

"You play with a Mac until you break it,
You play with a PC until it works."


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=sts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to