Chapter 1: ColdFusion Tags
19
CFBREAK
Used to break out of a CFLOOP. See Breaking out of a loop, later in this chapter, for
more information.
Syntax
<CFBREAK>
Example
<!--- This example shows the use of CFBREAK to exit
a loop when a condition is met --->
<!--- select a list of courses and use CFLOOP to find a condition
and then break the loop --->
<CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
SELECT *
FROM courses
ORDER by Number
</CFQUERY>
<HTML>
<HEAD>
<TITLE>
CFBREAK Example
</TITLE>
</HEAD>
<BODY bgcolor=silver>
<H1>CFBREAK Example</H1>
<P>This example uses CFLOOP to cycle through a query to find a desired
value. (In our example, a list of values corresponding to courses in the
cfsnippets datasource).
When the conditions of the query are met, CFBREAK stops the loop.
...
<!--- loop through the query until desired value is found,
then use CFBREAK to exit the query --->
<CFLOOP QUERY="GetCourses">
<CFIF GetCourses.Number is form.courseNum>
<CFOUTPUT>
<H4>Your Desired Course was found:</H4>
<PRE>#Number##Descript#</PRE></CFOUTPUT>
<CFBREAK>
<CFELSE>
<BR>Searching...
</CFIF>
</CFLOOP>
</CFIF>
</BODY>
</HTML>
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...