About ColdFusion Expressions  
 
 

At a basic level, you use expressions in ColdFusion application pages to perform operations on data. Since you can embed expressions in ColdFusion Markup Language (CFML) tags and CFScript blocks, you can create standard programming logic to manipulate data.

For example, you can use expressions in the ColdFusion tags CFSET and CFIF to create standard IF-ELSE statements:

<CFIF 1 + 1 is 2>
    The world is rational.<BR>
<CFELSE>
    Go home, today's a bad day.<BR>
</CFIF>

Some of the uses for expressions are to:

  • Perform mathematical calculations.
  • Manipulate strings.
  • Execute date-and-time operations.
  • Format dates, times, and numbers.
  • Add data to arrays and structures.
 
 
  What's in an expression?  
 
 

Expressions can contain a wide variety of objects or elements. Expressions can be built using the following components:

  • Basic terms: numbers, strings, Boolean (logical) values, date-and-time objects, lists, and complex objects like arrays, structures, queries, and COM objects
  • Variables that store some previously computed data
  • Functions that manipulate data in predefined ways
  • Operators that combine simple expressions to create more complex ones
 
 
  Expression examples  
 
 

For example:

  • 1 + 1 is a mathematical expression that evaluates to 2.
  • 1 is 2 is a logical expression that evaluates to the string NO (also the Boolean value FALSE).
  • Left("Monkey", 4) is a string expression that evaluates to the string Monk.
  • DateFormat(CreateDate(1998, 9, 11), "dddd, mmmm d, yyyy") is a date-and-time formatting operation that evaluates to Friday, September 11, 1998.

See the CFML Language Reference for a full catalog of ColdFusion tags and functions.



 
 
BackUp LevelNext
 
 

allaire     AllaireDoc@allaire.com
    Copyright © 1998, Allaire Corporation. All rights reserved.