User Guide
Chapter 1: ColdFusion Tags 43
Example <!--- This example shows the use of CFEXIT, and
is a read-only example --->
<HTML>
<HEAD>
<TITLE>CFEXIT Example</TITLE>
</HEAD>
<BODY>
<H3>CFEXIT Example</H3>
<P>CFEXIT can be used to abort the processing of the
currently executing CFML custom tag. Execution will resume
immediately following the invocation of the custom tag in the
page that called the tag.
<H3>Usage of CFEXIT</H3>
<P>CFEXIT is used primarily to perform a conditional stop
of processing inside of a custom tag. CFEXIT returns control
to the page that called that custom tag, or in the case of
a tag called by another tag, to the calling tag.
<!--- CFEXIT can be used inside a CFML custom tag, as
follows: --->
<!--- Place this code (uncomment the appropriate
sections) inside the CFUSION/customtags directory --->
<!--- MyCustomTag.cfm --->
<!--- This simple custom tag checks for the existence
of myValue1 and myValue2. If they are both defined,
the tag adds them and returns the result to the calling
page in the variable "result". If either or both of the
expected attribute variables is not present, an error message
is generated, and CFEXIT returns control to the
calling page. --->
<!--- <CFIF NOT IsDefined("attributes.myValue2")>
<CFSET caller.result = "Value2 is not defined">
<CFEXIT METHOD="ExitTag">
<CFELSEIF NOT IsDefined("attributes.myValue1")>
<CFSET caller.result = "Value1 is not defined">
<CFEXIT METHOD="ExitTag">
<CFELSE>
<CFSET value1 = attributes.myValue1>
<CFSET value2 = attributes.myValue2>
<CFSET caller.result = value1 + value2>
</CFIF> --->
<!--- End MyCustomTag.cfm --->
<!--- And place this code inside your page --->
<!--- <P>The call to the custom tag, and then the result:
<CF_myCustomTag
myvalue2 = 4>
<CFOUTPUT>#result#</cFOUTPUT> --->