Carol,

Not sure what you problem is (CFML errors or unexpected results), but here
is some docs from CF Studio:

switch-case: switch (expr) {case const-expr : statement break ; default :
statement }

In this syntax, const-expr must be a constant (i.e., not a variable, a
function, or other expression). Only one default statement is allowed. There
can be multiple case statements. You cannot mix Boolean and numeric case
values in a switch statement.

No two constants may be the same inside a switch statement.

switch(name)
{
    case "John":
    {
        male=true;
        found=true;
        break;
    }
    case "Mary":
    {
        male=false;
        found=true;
        break;
    }
    default:
    {
        found=false;
        break;
    }
} //end switch


Note:  That each statement must have a break; in it, or it will continue
thru each case.  Hope that helps!

So, not " around the variable name in the switch


Jim Reilly


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 04, 2001 3:34 PM
To: CF-Talk
Subject: CFSCRIPT "switch" Brain Burp


Looking for cfscript guru...

I know the answer to this is sooooo simple, but I have tried everything...I
think...
and the next step right now seems to be... asprin, chicken soup and
medication.

I tried:
switch abc; switch 'abc', switch '#abc#', switch #abc#;
switch (abc); switch ('abc'), switch ('#abc#'), switch (#abc#);

and in the output, when the program doesn't get caught up in errors due
to ' or " or #,   abc = r and txt_status always = Unknown

I just don't know what to do next.

What is the secret? how do i script the switch "???abc???" so it works?  

<CFSCRIPT>
    abc = 'r';
    switch (???abc???) {
        case "s":{txt_status = 'Initial Submission';}
        case "r":{txt_status = ' Revision';}
        case "a":{txt_status = 'Administration Revision';}
        case "j":{txt_status = 'Previously Rejected';}
        case "p":{txt_status = 'Processed and updated';}
        case "d":{txt_status = 'Previously Deleted';}
        default:{txt_status = 'Unknown';}
    }
    
</CFSCRIPT>
<CFOUTPUT>#abc#<BR>#txt_status#</CFOUTPUT>

Thank you, in advance, 
Carol



Carol L. Bluestein
Senior Programmer
NYS Office of Real Property
518-486-6335
[EMAIL PROTECTED]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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