IIRC, yes, all of the case values in a cfswitch are evaluated independently.
So, in this case, you'd run the switch case order the same way you listed
your if order (which, as Jeff pointed out, is backwards).  The last case to
evaluate to true would be the one to set the final value of ad.category, so
you want to list them from least specific to most specific.


  --Ben Doom
    Programmer & General Lackey
    Moonbow Software

: -----Original Message-----
: From: Jeff Beer [mailto:jbeer@;dbactive.com]
: Sent: Wednesday, October 30, 2002 10:34 AM
: To: CF-Talk
: Subject: RE: CFIF and CFSWITCH brain freeze
:
:
: Reverse the evaluation order.
:
: Since CGI.ScriptName DOES contain default.cfm it evaluates as TRUE and
: never looks at the other conditions.
:
: -----Original Message-----
: From: Pete Ruckelshaus [mailto:cflist@;ruckelshaus.com]
: Sent: Wednesday, October 30, 2002 10:22 AM
: To: CF-Talk
: Subject: CFIF and CFSWITCH brain freeze
:
:
: I'm having a brain freeze on the differences between how CFIF and
: CFSWITCH statements are handled.
:
: How I understand it: CFSWITCH evaluates all expressions "independently"
: (i.e. with no regard to other CFCASE values) while CFIF evaluates
: expressions serially (i.e. from first to last).  Is this statement true?
: Here's the reason I'm asking.
:
: First off, I'm doing this logic inside of a CFSCRIPT block, not that it
: should make any difference.
:
: I have this script:
:
: <cfscript>
:  IF (CGI.script_name CONTAINS "/default.cfm") {
:   ad.category = "1";}
:  ELSE IF (CGI.script_name CONTAINS "/directory/default.cfm") {
:   ad.category = "2";}
:  ELSE IF (CGI.script_name CONTAINS
: "/directory/subdirectory/default.cfm") {
:   ad.category = "3";}
:  ELSE
:   ad.category = "0";
: </cfscript>
:
: In this example, If I am on /directory/default.cfm, "2" should be set as
: the ad.category value and not "1", correct?  I just want to make sure
: that my assumptions are safe before I go too much further on this.
:
: Thanks,
:
: Pete
:
:
: 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to