Building Expressions - MACROMEDIA COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION MX Getting Started

Building coldfusion mx applications
Table of Contents

Advertisement

Building expressions

In ColdFusion, you build expressions as you need them. The expressions can include simple
elements, such as the expressions shown previously, or they can include complex elements, such
as arithmetic functions, strings, and decision operators. (You build some complex expressions in
Part II of this book.)
As mentioned, it is important that elements are identified properly in your expression so
ColdFusion processes them as expected, and you can avoid unnecessary errors. When writing
expressions, consider the following coding practices:
Character case consistency
When to use the pound (#) sign
When quotation marks are needed
Specifying a consistent character case
Because the ColdFusion server is case-insensitive, you can write expressions using all uppercase,
all lowercase, or mixed case. However, for code readability and consistency, you should use the
same character case in all your programs. If you write your programs using the same case rules,
you might prevent errors from occurring when you combine CFML on a page with case-sensitive
languages, such as JavaScript.
Specifying pound signs to denote functions or variables
In ColdFusion, you specify pounds signs to denote functions and variables within a string of text.
You use pounds signs to show the results of the function or variable on the page. Pounds signs
instruct the ColdFusion server to evaluate the function (or variable) between the pound signs and
display the value. The value of the function (or variable) appears in the browser as a result.
The following list identifies some common ways to use pound signs:
In the following example, you include the pound signs to return the value to a page:
<cfoutput> Hello #variables.my_first_name# </cfoutput>
If you omit the pound signs, the text, not the value, appears on the page.
In the following example, you do not include the pound signs because you are using
assign one variable's value to another value:
<cfset my_full_name = variables.my_first_name & " " &
variables.my_last_name>
To display a pound sign on a page, you must designate the pound sign as a literal character.
You do this by using two pound signs (##); for example:
<cfoutput>
##1: Your name.
</cfoutput>
The result is the following output:
#1. Your name.
For more information and examples on using pound signs in expressions, see Developing
ColdFusion MX Applications.
24
Chapter 2: CFML Basics
to
cfset

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents