Dynamic Expressions And Dynamic Variables; About Dynamic Variables; About Dynamic Expressions And Dynamic Evaluation - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Dynamic expressions and dynamic variables

This section discusses the advanced topics of dynamic expressions, dynamic evaluation, and
dynamic variable naming. Many ColdFusion programmers never encounter or need to use
dynamic expressions. However, dynamic variable naming is important in situations where the
variable names are not known in advance, such as in shopping cart applications.
This section also discusses the use of the
expressions. This function dynamically evaluates its arguments, and you must often use the
function to prevent the evaluation. For more information on using the
the IIF function" on page 98
Note: This section uses several tools and techniques that are documented in later chapters. If you are
unfamiliar with using ColdFusion forms, structures, and arrays, you should learn about these tools
before reading this section.

About dynamic variables

Dynamic variables are variables that are named dynamically, typically by creating a variable name
from a static part and a variable part. For example, the following example dynamically constructs
the variable name from a variable prefix and a static suffix:
<cfset "#flavor#_availability" = "out of stock">
Using dynamic variables in this manner does not require dynamic evaluation.

About dynamic expressions and dynamic evaluation

In a dynamic expression, the actual expression, not just its variable values, is determined at
execution time. In other words, in a dynamic expression the structure of the expression, such as
the names of the variables, not just the values of the variables, gets built at runtime.
You create dynamic expressions using string expressions, which are expressions contained in strings,
(that is, surrounded with quotation marks). Dynamic evaluation is the process of evaluating a
string expression. The
evaluation.
When ColdFusion performs dynamic evaluation it does the following:
Takes a string expression and treats it as a standard expression, as if the expression was not a
1
string.
Parses the expression to determine the elements of the expression and validate the expression
2
syntax.
Evaluates the expression, looking up any variables and replacing them with their values, calling
3
any functions, and performing any required operations.
This process enables ColdFusion to interpret dynamic expressions with variable parts. However, it
incurs a substantial processing overhead.
Dynamic expressions were important in early versions of ColdFusion, before it supported arrays
and structures, and they still can be useful in limited circumstances. However, the ability to use
structures and the ability to use associative array notation to access structure elements provide
more efficient and easier methods for dynamically managing data. For information on using
arrays and structures, see
92
Chapter 4: Using Expressions and Pound Signs
IIf
.
and
functions, and only these functions, perform dynamic
Evaluate
IIf
Chapter 5, "Using Arrays and Structures," on page
function, which is most often used without dynamic
DE
function, see
"Using
IIF
103.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents