Using Pound Signs In Tag Bodies; Using Pound Signs In Strings - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Note: You do not need to use pound signs when you use the
to another value. For example, the following tag assigns the value of the oldVar variable to the new
variable, newVar: <cfset newVar = oldVar>.

Using pound signs in tag bodies

You can put variables or functions freely inside the bodies of the following tags by enclosing each
variable or expression with pound signs:
cfoutput
cfquery
cfmail
For example:
<cfoutput>
Value is #Form.MyTextField#
</cfoutput>
<cfoutput>
The name is #FirstName# #LastName#.
</cfoutput>
<cfoutput>
The value of Cos(0) is #Cos(0)#
</cfoutput>
If you omit the pound signs, the text, rather than the value, appears in the output generated by
the
statement.
cfoutput
Two expressions inside pound signs can be adjacent to one another, as in the following example:
<cfoutput>
"Mo" and "nk" is #Left("Moon", 2)##Mid("Monkey", 3, 2)#
</cfoutput>
This code displays the following text:
"Mo" and "nk" is Monk
ColdFusion does not interpret the double pound sign as an escaped # character.

Using pound signs in strings

You can put variables or functions freely inside strings by enclosing each variable or expression
with pound signs; for example:
<cfset TheString = "Value is #Form.MyTextField#">
<cfset TheString = "The name is #FirstName# #LastName#.">
<cfset TheString = "Cos(0) is #Cos(0)#">
ColdFusion automatically replaces the text with the value of the variable or the value returned by
the function. For example, the following pairs of
<cfset TheString = "Hello, #FirstName#!">
<cfset TheString = "Hello, " & FirstName & "!">
If pound signs are omitted inside the string, the text, rather than the value, appears in the string.
For example, the following pairs of
<cfset TheString = "Hello, FirstName!">
<cfset TheString = "Hello, " & "First" & "Name!">
90
Chapter 4: Using Expressions and Pound Signs
statements produce the same result:
cfset
statements produce the same result:
cfset
cfset
tag to assign one variable's value

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion mx

Table of Contents