View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > DE PreviousNext

DE

Postpones evaluation of a string as an expression, when it is passed as a parameter to the IIf or Evaluate functions. Escapes any double quotation marks in the parameter and wraps the result in double quotation marks.

This function is especially useful with the IIf function, to prevent the function from evaluating a string that is to be output.

This applies to expressions that are not surrounded by pound signs. (If pound signs surround any part of an expression, a ColdFusion function evaluates that part first, regardless of whether the DE function is present.)

Parameter, surrounded by double quotation marks, with any inner double quotation marks escaped.

Dynamic evaluation functions

DE(string)

Evaluate, IIf

Parameter

Description

string

String to evaluate, after delay

Consider this example:

<condition> <true expression> <false expression>
IIf( 1 eq 2, DE('#Var1#'), DE('#Var2#'))

ColdFusion evaluates whatever is surrounded by pounds in the expression before executing it. So, although this expression is never true (because Var1 does not exist), the expression fails with an 'Error Resolving Parameter' error, because ColdFusion evaluates #Var1#' and #Var2#' before executing either expression.

This example returns 'Var2':

IIf( 1 eq 2, DE('Var1'), DE('Var2')) 

The following example uses IIF to alternate table-row background colors, white and gray. It uses the DE function to prevent ColdFusion from evaluating the color strings.

<cfoutput>
<table border="1" cellpadding="3">
<cfloop index="i" from="1" to="10">
   <tr bgcolor="#IIF( i mod 2 eq 0, DE("white"), DE("gray") )#">
      <td>
         hello #i#
      </td>
   </tr>
</cfloop>
</table>
</cfoutput>

For more information and code examples, see Using Expressions and Pound Signs in Developing ColdFusion MX Applications.

<!--- This example shows the use of DE and Evaluate --->
<h3>DE Example</h3>
<cfif IsDefined("FORM.myExpression")>
<h3>The Expression Result</h3>
<cftry>
<!--- Evaluate the expression --->
<cfset myExpression = Evaluate(FORM.myExpression)>
<!--- Use DE to output the value of the variable, unevaluated --->
<cfoutput>
<I>The value of the expression #Evaluate(DE(FORM.MyExpression))#
is #MyExpression#.</I>
</cfoutput>
<!--- specify the type of error for which we are searching --->
<cfcatch type = "Any">
<!--- the message to display --->
   <h3>Sorry, there's been an <B>Error</B>.
   Try a simple expression, such as "2+2".</h3>
<cfoutput>
<!--- and the diagnostic message from ColdFusion Server --->
  <p>#cfcatch.message#
</cfoutput>
</cfcatch>
</cftry>
</cfif>

Contents > CFML Reference > ColdFusion Functions > DE PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


halL said on Jun 3, 2004 at 11:18 AM :
This page is a little confusing and needs revision.
Problems include:

The discussion of pound signs should probably clarify that "escaping a double pound sign" means doubling it (as in ""), and that in an expression such as DE("myVar"), the surrounding poind signs are NOT escaped. It could also discuss use of single pound signs to surround text in double pound signs.

The third paragraph, which starts with "This", should read something like the following:
The DE function delays the evaluation of expressions only if they are not in pound signs. If you surround any part of a DE function parameter in pound signs, ColdFusion evaluates the text in the pound signs before it processes the DE function, so it cannot delay the evaluation.

It is not clear that <condition> <true expression> <false expression> are meant to describe the three parameters of the IIF tag.

The statement " this expression is never true (because Var1 does not exist), " leaves the meaining of "this expression" unclear (and I'm not quite sure what it intends to say.
The idea of the IIf( 1 eq 2, DE('#Var1#'), DE('#Var2#')) example is to say that DE does not delay ColdFusion's evaluating Var1 and encountering an error.

I think we should omit the single pound signs in the sentence "This example returns 'Var2':" to ensure that it is clear that no single pound signs are returned.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functi67.htm