your using all the time with a single alteration. I use braces for each
case. Try this:
switch(_expression_)
{
case "valuea":
case "valueb":
{
stuff;
break;
}
case "valuec":
{
stuff;
break;
}
default:
{
break;
}
}
I know the extra braces don't look important, but they may be. Using this on
CFMX 6.1 I have no problems.
> I posted the other day about a way to have multipile values apply to the
> same case logic when writing a switch block in cfscript. It went like
> this:
>
> switch(_expression_) {
> case "valuea":
> case "valueb":
> stuff;
> break;
>
> case "valuec":
> stuff;
> break;
>
> default:
> break;
> }
>
> I have run this syntax in CF5 successfully. Just now I tried the same on
> a box with CFMX 6.1 and I get this error:
>
> Context validation error for tag CFCASE.
> The CFSWITCH has a duplicate CFCASE for value "1.0".
>
> So, the behavior has changed it seems to me. Can anyone else validate
> this? Also, is it a bug? Or was it "fixed" because it shouldn't have
> been working the way it did in CF 5?
>
> FYI, here is the specifc code I was running:
>
> function convertBooleanOrNull(target) {
> var value = "NULL";
> switch (target) {
> case "Y":
> case "Yes":
> case true:
> value = True;
> break;
> case "N":
> case "No":
> case false:
> value = False;
> break;
> }
> return value;
> }
>
>
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

