Adobe COLDFUSION 9 Manual page 120

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
if(score GT 1)
result = "positive";
else
result = "negative";
CFScript does not include an elseif statement. However, you can use an
statement to create the equivalent of a
if(score GT 1)
result = "positive";
else if(score EQ 0)
result = "zero";
else
result = "negative";
As with all conditional processing statements, you can use curly brackets to enclose multiple statements for each
condition, as follows:
if(score GT 1) {
result = "positive";
message = "The result was positive.";
}
else {
result = "negative";
message = "The result was negative.";
}
Note: Often, you can make your code clearer by using braces even where they are not required.
Using switch and case statements
The
statement and its dependent
switch
switch (expression) {
case constant: [case constant:]... statement(s) break;
[case constant: [case constant:]... statement(s) break;]...
[default: statement(s)] }
Use the following rules and recommendations for
• You cannot mix Boolean and numeric constant values in a
• Each constant value must be a constant (that is, not a variable, a function, or other expression).
• Multiple
constant: statements can precede the statement or statements to execute if any of the cases are true.
case
This lets you specify several matches for one code block.
• No two constant values can be the same.
• The statements following the colon in a
equals the
expression, ColdFusion executes all statements through the
switch
• The
statement at the end of the
break
does not generate an error message if you omit a
the statements in the following case statement, even if that case is false. In nearly all circumstances, this is not what
you want to do.
• You can have only one
default
block if none of the
default
tag, as the following example shows:
cfelseif
and
case
default
statements:
switch
statement block do not have to be in curly brackets. If a constant value
case
statement tells ColdFusion to exit the
case
statement. However, if you omit it, ColdFusion executes all
break
statement in a
statement block. ColdFusion executes the statements in the
switch
statement constants equals the expression value.
case
Last updated 8/5/2010
statement immediately after an
if
statements have the following syntax:
statement.
switch
statement.
break
switch
115
else
statement. ColdFusion

Advertisement

Table of Contents
loading

Table of Contents