Expressions

Expressions are the building blocks of the CFML language. In its most basic form, an expression is nothing more than a single element such as 1, test, MyVar, or Chr(54). Compound expressions let you to evaluate data that is acted upon by operators. For example, 1*10 is a mathematical expression that evaluates to 10. The values 1 and 10 are both data, while the asterisk (*) is considered an operator. On the other end of the spectrum, expressions can be complex, consisting of one or more subexpressions:

<cfset x = 1+(10 mod (3 * (11 - acos(-1))))>

Operators

Operators allow you to perform calculations and make comparisons between expressions. In other words, they allow you to combine simple expressions to form ones that are more complex. For example, <cfset x = 10*(3+2)> uses the asterisk (*) as an operator to multiply 10 by the sum of another expression that uses the plus (+) operator to add 3 and 2. There are four types of operators available in ColdFusion:

Arithmetic

Performs arithmetic operations such as sign changes, addition, subtraction, etc., on numeric values.

Comparison

Compares two values and returns a Boolean true/false.

String

There is only one string operator in the CFML language. The ampersand (&) concatenates strings.

Boolean

Also known as logical operators, Boolean operators perform connective and negation operations and return Boolean true/false values.

Table 2-2 lists the operators available in ColdFusion by order of precedence (P).

Table 2-2. ColdFusion ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.