> 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>
Your problem doesn't have anything to do with the switch part. This:
switch(abc) will work fine.
The problem is that, with switch in CFSCRIPT, unless you include a break
after each case, it'll jump to the right case, but then execute each
following case all the way down. For example, this:
<cfscript>
testvar = "Curly";
switch (testvar) {
case "Larry" : outputvar = "1";
case "Curly" : outputvar = "2";
case "Moe" : outputvar = "3";
default : outputvar = "other";
}
</cfscript>
<cfoutput>Stooge #outputvar#</cfoutput>
will output this:
"Stooge other"
With the breaks, though:
<cfscript>
testvar = "Curly";
switch (testvar) {
case "Larry" : outputvar = "1";
break;
case "Curly" : outputvar = "2";
break;
case "Moe" : outputvar = "3";
break;
default : outputvar = "other";
}
</cfscript>
<cfoutput>Stooge #outputvar#</cfoutput>
you'll get "Stooge 2".
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists