Sir Isaac - I bow to your wisdom.  I have never seen it in that context.

-----Original Message-----
From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 10, 2002 12:59 PM
To: CF-Talk
Subject: Re: multiple case values in switch statement in cfscript


> Hi

> Could anyone tell me if its possible to define multiple case statements
> In a switch block in cfscript..

> So a cfscript version of :

> <cfcase = "a,b,c,d,e" >


Yes it is.

CFScript uses standard C/C++/Java/JavaScript syntax for switch/case, so the
cfscript equivalent looks like this:

switch (exp) {
        case "a": { ; }
        case "b": { .. do something ... }
        case "c": { .. do something ... break; }
        default: { ... do something ... }
}

The case expressions cascade, so from the point that your case evaluates, to
the point that you insert a break; in your case statements is what portion
of the code will execute, thus, if the value of exp is a or b, in the
example above, all of the actions ( or lack thereof in the case of a ) will
occur for cases a,b and c. If the value of exp is c then only the action for
c will occur. The default actions will not be processed unless something
other than a b or c is found in the value of exp because of the break; at
the end of the actions for c.

hth

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to