<CFSWITCH> Tag - ColdFusion


>> Return to CF Tag List

The <CFSWITCH> tag allows you ...



  <CFSWITCH> Comments from Macromedia LiveDocsLiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-c10.htm
switch thinks "00" and "0A" are both "0.0"....

function Hex7toStr(Char){
switch (Char)
{
case "00":
newchar = "NUL";
break;
case "0A":
newchar = "LF";
break;
}
return newchar;
}

Is this expected behaviour?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-c10.htm
Switch and Case take strings the documentation should explicitely say whether these tags are case-sensitive.

Also, the doc says that the expression should evaulate to a scalar. Is a string normally considered a scalar value?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-c10.htm
Your example doesn't throw an error, but there's no CFML code outside of the CFCASE tags. If you were to alter your code as in the following example, you would see that ColdFusion throws an error when it encounters the CFOUTPUT.
<CFSET x=1>
<CFSWITCH EXPRESSION="#x#">
<CFCASE VALUE="0">test1</CFCASE>
<CFOUTPUT>The value of x is #x#.</CFOUTPUT>
<CFCASE VALUE="2">test2</CFCASE>
not in case 2
</CFSWITCH>

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-c10.htm
This page states:
"All code within this tag must be within a cfcase or cfdefaultcase tag. Otherwise, ColdFusion throws an error."
This statement is not true (at least in CF MX 6.1), the following code runs just fine:
<CFSET x=1>
<CFSWITCH EXPRESSION="#x#">
<CFCASE VALUE="0">test1</CFCASE>
not in case 1
<CFCASE VALUE="2">test2</CFCASE>
not in case 2
</CFSWITCH>



[Top]


Recommended Books

[Top]

Web Sites

[Top]

Copyright © 2003- 2010, Orville Paul Chomer, All Rights Reserved