Home arrow ColdFusion arrow Page 5 - What You Must Know About ColdFusion Flow-Controls

What You Must Know About ColdFusion Flow-Controls

Flow control tags exist to control how a program proceeds. Coldfusion uses conditional processing tags to control the flow. This article covers some of the more important flow control tags in the language, as well as script equivalents.

Author Info:
By: Jayaram Krishnaswamy
Rating: 5 stars5 stars5 stars5 stars5 stars / 7
September 14, 2005
  1. · What You Must Know About ColdFusion Flow-Controls
  2. · What if, and where to scenarios
  3. · Which way to go?
  4. · Keep looking until you find
  5. · Breaking out of loops
  6. · Call a halt and end

print this article

What You Must Know About ColdFusion Flow-Controls - Breaking out of loops
(Page 5 of 6 )

The <cfbreak> tag

Sometimes you may not want to cycle through the whole loop, but only verify a few; then you want break out of the loop. While testing your code in loops, often times you may run into a condition of an infinite loop, a condition you may not be able to get out unless you abandon the program by ending it. In such cases, it will be prudent to put in a break which gives you an opportunity to check your code. The switch construct we saw earlier is another place where a break is used. The break is implemented by the <cfbreak> tag. The syntax is:

Example 11

This is the same as previous example with a slight modification. After the variable vol gets incremented, it is quizzed in the <cfif> conditional for a value of 7. When the value becomes 7, the if condition is satisfied and the processing reaches <cfbreak>. This is when the loop is broken. Whatever value the variable had up to that time is what is displayed.

<cfset vol=5>
<cfloop condition="#vol# lt 10">
<cfoutput>Count is  #vol#</cfoutput><br/>
<cfset #vol#=#vol#+1>
<cfif #vol# gt 7>

The displayed output when this code is run is as follows:

Count is 5
Count is 6
Count is 7

blog comments powered by Disqus

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials