User Guide

Table Of Contents
Dynamic expressions and dynamic variables 87
Using dynamic evaluation
The following sections describe how to use dynamic evaluation and create dynamic expressions.
ColdFusion dynamic evaluation functions
The following table describes the functions that perform dynamic evaluation and are useful in
evaluating dynamic expressions:
Function argument evaluation considerations
It is important to remember that ColdFusion always evaluates function arguments before the
argument values are passed to a function:
For example, consider the following
DE function:
<cfoutput>#DE("1" & "2")#</cfoutput>
You might expect this line to display """1"" & ""2""". Instead, it displays “12”, because
ColdFusion processes the line as follows:
1.
Evaluates the expression "1" & "2" as the string “12”.
2.
Passes the string "12" (without the quotation marks) to the DE function.
3.
Calls the DE function, which adds literal quotation marks around the 12.
Similarly, if you use the expression DE(1 + 2), ColdFusion evaluates 1 + 2 as the integer 3 and
passes it to the function. The function converts it to a string and surrounds the string in literal
quotation marks: “3”.
Function Purpose
DE Escapes any double-quotation marks in the argument and wraps the result in
double-quotation marks. The
DE function is particularly useful with the IIF
function, to prevent the function from evaluating a string to be output.
For an example of using the
DE function with the IIF function, see “Using the IIF
function” on page 90.
Evaluate Takes one or more string expressions and dynamically evaluates their contents
as expressions from left to right. (The results of an evaluation to the left can have
meaning in an expression to the right.) Returns the result of evaluating the
rightmost argument.
For more information on this function see “About the Evaluate function”
on page 88.
IIf Evaluates a boolean condition expression. Depending on whether this
expression is True or False, dynamically evaluates one of two string expressions
and returns the result of the evaluation. The
IIF function is convenient for
incorporating a
cfif tag in-line in HTML.
For an example of using this function, see “Using the IIF function” on page 90.
SetVariable Sets a variable identified by the first argument to the value specified by the
second argument. This function is no longer required in well-formed ColdFusion
pages; see “SetVariable function considerations” on page 90.