Chapter 4: ColdFusion Expressions: Operators and Other Constructs
581
Pound Signs
Pound signs (#) have special meaning in ColdFusion. When a CFML application page
is processed, ColdFusion treats text delimited by pound signs differently from plain
text.
Two simple and very important points about pound signs in CFML are:
•
Use pound signs to distinguish expressions from plain text.
•
When expressions are evaluated, the resulting value is substituted for the
expression text.
For example, to output the current value of a variable named “Form.MyFormVariable,”
you must delimit the variable name with pound signs:
<CFOUTPUT>Value is #Form.MyFormVariable#</CFOUTPUT>
When ColdFusion processes an expression, it replaces the text of the expression and
the two pound signs around it with its resulting value. In the example above, the
expression #Form.MyFormVariable# is replaced with whatever value has been
assigned to it.
While the guidelines for using pound signs in CFML are simple, there is still some
possibility for confusion to arise. This is particularly true in cases where expressions
and plain text are mixed together. The following sections provide more details on how
pound signs should be used in CFML.
Pound signs inside CFOUTPUT tags
Expressions containing a single variable or a single function can be used freely inside
CFOUTPUT tags as long as they are enclosed in pound signs.
<CFOUTPUT>
Value is #Form.MyTextField#
</CFOUTPUT>
<CFOUTPUT>
The name is #FirstName# #LastName#.
</CFOUTPUT>
<CFOUTPUT>
Cos(0) is #Cos(0)#
</CFOUTPUT>
If pounds are not used around these expressions, the expression text rather than the
expression value will appear in the output generated by the CFOUTPUT statement.
Note that two expressions inside pound signs can be adjacent to one another, as in
<CFOUTPUT>
"Mo" and "nk" is #Left("Moon", 2)# #Mid("Monkey", 3, 2)#
</CFOUTPUT>
Summary of Contents for COLDFUSION 4.5-CFML LANGUAGE
Page 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Page 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Page 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Page 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Page 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Page 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Page 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Page 584: ...560 CFMLLanguageReference...
Page 594: ...570 CFMLLanguageReference...