Adobe COLDFUSION 9 Manual page 72

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Note: In CFScript expressions only, you can also use the following decision operators. You cannot use them in expressions
in tags. == (EQ), != (NEQ), > (GT), < (LT), >= (GTE), and <= (LTE).
Decision operator rules
The following rules apply to decision operators:
• When ColdFusion evaluates an expression that contains a decision operator other than CONTAINS or DOES NOT
CONTAIN, it first determines if the data can be converted to numeric values. If they can be converted, it performs
a numeric comparison on the data. If they cannot be converted, it performs a string comparison. This can
sometimes result in unexpected results. For more information on this behavior, see
conversion
issues" on page 53.
• When ColdFusion evaluates an expression with CONTAINS or DOES NOT CONTAIN it does a string
comparison. The expression A CONTAINS B evaluates to True if B is a substring of A. Therefore an expression
such as the following evaluates as True:
123.45 CONTAINS 3.4
• When a ColdFusion decision operator compares strings, it ignores the case. As a result, the following expression is
True:
"a" IS "A"
• When a ColdFusion decision operator compares strings, it evaluates the strings from left to right, comparing the
characters in each position according to their sorting order. The first position where the characters differ
determines the relative values of the strings. As a result, the following expressions are True:
"ab" LT "aba"
"abde" LT "ac"
String operators
String operators manipulate strings of characters. The following table describes the operators:
Operator
Description
&
Concatenates strings.
&=
Compound concatenation. The variable on the right is used as both an element in the concatenation operation and
the result variable. Thus, the expression
An expression can have only one compound assignment operator.
Note: In a Query of Queries, you use || as the concatenation operator.
Ternary Operator
The ternary operator is a decision operator with three operands. It assigns a variable a value based on a Boolean
expression. The operator has the form
(Boolean expression)? expression1 : expresson2
If the Boolean expression evaluates to
For example
<cfset c = (a GT b)? a : b >
If
is greater than
,
is assigned the value of
a
b
c
is equivalent to
a &= b
, the operator result is
true
expression1
; otherwise,
is assigned the value of
a
c
Last updated 8/5/2010
"Evaluation and type
.
a = a & b
; otherwise, it is
expression2
.
b
67

Advertisement

Table of Contents
loading

Table of Contents