210
CFML Language Reference
CFSWITCH/CFCASE/CFDEFAULTCASE
Used with CFCASE and CFDEFAULTCASE, the CFSWITCH tag evaluates a passed
expression and passes control to the CFCASE tag that matches the expression result.
You can optionally code a CFDEFAULTCASE tag, which receives control if there is no
matching CFCASE tag value.
Syntax
<CFSWITCH EXPRESSION="expression">
<CFCASE VALUE="value" DELIMITERS="delimiters">
HTML and CFML tags
</CFCASE>
additional <CFCASE></CFCASE> tags
<CFDEFAULTCASE>
HTML and CFML tags
</CFDEFAULTCASE>
</CFSWITCH>
EXPRESSION
Required. Any ColdFusion expression that yields a scalar value. ColdFusion
converts integers, real numbers, Booleans, and dates to numeric values. For
example, TRUE, 1, and 1.0 are all equal.
VALUE
Required. One or more constant values that CFSWITCH compares to the specified
expression (case-insensitive comparison). If a value matches the expression,
CFSWITCH executes the code between the CFCASE start and end tags.
Separate multiple values with a comma or an alternative delimiter, as specified in
the DELIMITERS parameter. Duplicate value attributes are not allowed and will
cause a runtime error.
DELIMITERS
Optional. Specifies the character that separates multiple entries in a list of values.
The default delimiter is the comma (,).
Usage
Use CFSWITCH followed by one or more CFCASE tags, optionally ending with a
CFDEFAULTCASE tag. The CFSWITCH tag selects the matching alternative from the
specified CFCASE and CFDEFAULTCASE tags and jumps to the matching tag,
executing the code between the CFCASE start and end tags. There is no need to
explicitly break out of the CFCASE tag, as there is in some other languages.
You can specify only one CFDEFAULTCASE tag within a CFSWITCH tag. CFCASE tags
cannot appear after the CFDEFAULTCASE tag.
CFSWITCH provides better performance than a series of CFIF/CFELSEIF tags and the
resulting code is easier to read.
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...