Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFSWITCH, CFIF conditionals ... is there a shorter way?

Status
Not open for further replies.

RickForgo

Technical User
Jun 10, 2003
5
US
I'm familiar with how CFSWITCH and CFIF statements can be used to filter conditionals, but is there a shorter way?

Right now I'm using CFIFs to filter through data and to print data based on a conditional result. For example:

<CFIF #acronym# EQ &quot;A1&quot;>
<TD colspan=&quot;3&quot; CLASS=&quot;#Class#&quot; > <span class=&quot;maintext2&quot;><a href=&quot;c_amp_detail_01.cfm?amp_id=#amp_id#&amplan_year=#amplan_year#&cat=#cat#&quot;><font color=&quot;##000099&quot;>#equipment# (#acronym#)</font></a></span> <div align=&quot;left&quot;></div>
<CFELSEIF #acronym# EQ &quot;A2&quot;>
<TD colspan=&quot;3&quot; CLASS=&quot;#Class#&quot; > <span class=&quot;maintext2&quot;><a href=&quot;c_amp_detail_01.cfm?amp_id=#amp_id#&amplan_year=#amplan_year#&subcat=#subcat#&quot;><font color=&quot;##000099&quot;>#equipment#</font></a></span> <div align=&quot;left&quot;></div>
</CFIF>

But I've got multiple possibilities for the #acronym# data and I'm wondering if there's a shorter way to filter through the list; perhaps something akin to:

<CFIF #acronym# EQ &quot;A1&quot; OR &quot;A2&quot; OR &quot;A3&quot; OR &quot;A4&quot;>
<CFELSEIF #acronym# EQ &quot;B1&quot; OR &quot;B2&quot; OR &quot;B3&quot; OR &quot;B4&quot;>
HTML
</CFIF>

Is there a syntax equivalent to this?
 
Try this:

<CFIF #acronym# EQ &quot;A1&quot; OR #acronym# EQ &quot;A2&quot; OR #acronym# EQ &quot;A3&quot; OR #acronym# EQ &quot;A4&quot;>

Whatever
<CFELSEIF #acronym# EQ &quot;B1&quot; OR #acronym# EQ &quot;B2&quot; OR #acronym# EQ &quot;B3&quot; OR #acronym# EQ &quot;B4&quot;>
Whatever
</CFIF>

Hope this Helps

 
Or you could very easily use ListFind()... just almost bewards to how you're used to using it.

Code:
   <CFIF ListFindNoCase(&quot;A1,A2,A3,A4&quot;,acronym) GT 0>
        :
   <CFELSEIF ListFindNoCase(&quot;B1,B2,B3,B4&quot;,acronym) GT 0>
        :
   </CFIF>

Not only is it easier to code and maintain, but it's actually going to perform better than a bunch of OR's in your CFIF.



-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top