The following table illustrates the use of the Evaluate function:
Using the Evaluate Function
|
CFML expression
|
Result
|
Evaluate("2")
|
2
|
Evaluate("2 * (11 MOD 3)")
|
4
|
Evaluate("Form.MyFormVariable")
|
the value of Form.MyFormVariable
|
Evaluate("Min(X, Y)")
|
the smaller of the values of X and Y
|
Evaluate(DE("Some text"))
|
Some text
|
Evaluate(DE('A double quote "'))
|
A double quote "
|
The guidelines for calling the Evaluate function are shown below:
Guidelines for Calling the Evaluate Function
|
To get
|
Use
|
the result of (1 + A)
| Evaluate("1 + A")
|
the value of variable A
| Evaluate("A")
|
the number 2
| Evaluate("2")
|
the string A
| Evaluate(DE("A"))
|
Note the difference between the second and the fourth example. In the second example, we want to evaluate the expression A which should resolve to the value of the variable A (or an error if A does not exist). In the last example, we want to evaluate the expression "A" which should resolve to the text inside the string, or simply A. To inform ColdFusion of the difference (without worrying about escaping quotes), you call the DE function.
|