ColdFusion
  Home arrow ColdFusion arrow Page 5 - What You Must Know About ColdFusion Flow-C...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COLDFUSION

What You Must Know About ColdFusion Flow-Controls
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2005-09-14

    Table of Contents:
  • What You Must Know About ColdFusion Flow-Controls
  • What if, and where to scenarios
  • Which way to go?
  • Keep looking until you find
  • Breaking out of loops
  • Call a halt and end

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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:

    <cfbreak>
    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>
    <cfbreak>
    </cfif>
    </cfloop>
    

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

    
    Count is 5
    Count is 6
    Count is 7
    
    

    More ColdFusion Articles
    More By Jayaram Krishnaswamy


       · I again welcome you to the CF tutorials. In these tutorials, I want to present a...
     

    COLDFUSION ARTICLES

    - 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...
    - My First Application on ColdFusion MX Server


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway