Used to break out of a cfloop
.
<cfbreak>
cfabort,
cfexecute,
cfif cfelseif cfelse,
cflocation,
cfloop,
cfswitch cfcase cfdefaultcase,
cfthrow,
cftry cfcatch
<!--- 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 Course_Num </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 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 value is found, then use cfbreak to exit the query ---> <cfloop query = "GetCourses"> <cfif GetCourses.Course_Num 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>