50
Chapter 2: Elements of CFML
cfabort and cfexit
The
cfabort
tag stops processing of the current page at the location of the
cfabort
tag.
ColdFusion returns to the user or calling tag everything that was processed before the
cfabort
tag. You can optionally specify an error message to display. You can use the
cfabort
tag as the
body of a
cfif
tag to stop processing a page when a condition, typically an error, occurs.
The
cfexit
tag controls the processing of a custom tag, and can only be used in ColdFusion
custom tags. For more information see,
Chapter 9, “Terminating tag execution,” on page 185
and
CFML Reference
.
Comments
ColdFusion comments have a similar format to HTML comments. However, they use three dash
characters instead of two; for example:
<!--- This is a ColdFusion Comment. Browsers do not receive it. --->
The ColdFusion server removes all ColdFusion comments from the page before returning it to
the web server. As a result, the page that a user browser receives does not include the comment,
and users cannot see it even if they view the page source.
You can embed CFML comments in begin tags (not just tag bodies), functions calls, and variable
text in pound signs. ColdFusion ignores the text in comments such as the following:
<cfset MyVar = var1 <!--- & var2 --->>
<cfoutput>#Dateformat(now() <!---, "dddd, mmmm yyyy" --->)#</cfoutput>
This technique can be useful if you want to temporarily comment out parts of expressions or
optional attributes or arguments.
Note:
You cannot embed comments inside a tag name or function name, such as
<cf_My<!--- New -
-->CustomTag>
. You also cannot embed comments inside strings, as in the following example:
IsDefined("My<!--- New --->Variable")
.
Special characters
The double quotation marks ("), single quotation mark ('), and pound sign (#) characters have
special meaning to ColdFusion. To include any of them in a string, double the character; for
example, use ## to represent a single # character.
The need to escape the single- and double-quotation marks is context-sensitive. Inside a double-
quoted string, you do not need to escape single-quote (apostrophe) characters. Inside a single-
quoted string, you do not escape double-quote characters.
The following example illustrates escaping special characters, including the use of mixed single
and double quotes.
<cfset mystring = "We all said ""For He's a jolly good fellow.""">
<cfset mystring2 = 'Then we said "For She''s a jolly good fellow".'>
<cfoutput>
#mystring#<br>
#mystring2#<br>
Here is a pound sign: ##
</cfoutput>
Summary of Contents for ColdFusion MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......