User Guide

Table Of Contents
75
CHAPTER 4
Using Expressions and Number Signs
This chapter discusses how to use expressions in CFML. It discusses the elements of Macromedia
ColdFusion expressions and how to create expressions. It also describes the correct use of number
signs to indicate expressions in ColdFusion tags such as
cfoutput, in strings, and in expressions.
Finally, it describes how to use variables in variable names and strings to create dynamic
expressions, and dynamic variables.
Contents
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Using number signs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Dynamic expressions and dynamic variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Expressions
ColdFusion expressions consist of operands and operators. Operands are comprised of constants
and variables. Operators, such as the multiplication symbol, are the verbs that act on the
operands; functions are a form of operator.
The simplest expression consists of a single operand with no operators. Complex expressions have
multiple operators and operands. The following are all ColdFusion expressions:
12
MyVariable
(1 + 1)/2
"father" & "Mother"
Form.divisor/Form.dividend
Round(3.14159)
Operators act on the operands. Some operators, such as functions with a single argument, take a
single operand. Many operators, including most arithmetic and logical operators, take two
operands. The following is the general form of a two-operand expression:
Expression Operator Expression