home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfabort.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.4 KB  |  59 lines

  1. <!--- this example demonstrates the use of CFABORT
  2. to stop the processing of a CFLOOP.  Note that in
  3. the second example, where CFABORT is used,
  4. the result never appears --->
  5.  
  6. <HTML>
  7.  
  8. <HEAD>
  9. <TITLE>CFABORT Example</TITLE>
  10. </HEAD>
  11.  
  12. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  13. <BODY  bgcolor="#FFFFD5">
  14.  
  15. <H3>CFABORT Example</H3>
  16.  
  17. <P>
  18. <H3>Example A: Let the instruction complete itself</H3>
  19. <!--- first, set a variable  --->
  20. <CFSET myVariable = 3>
  21. <!--- now, perform a loop that increments this value --->
  22. <CFLOOP FROM="1" TO="4" INDEX="Counter">
  23.     <CFSET myVariable = myVariable + 1>
  24. </CFLOOP>
  25.  
  26. <CFOUTPUT>
  27. <P>    The value of myVariable after incrementing through the loop
  28.     #Counter# times is: #myVariable#
  29. </CFOUTPUT>
  30.  
  31.  
  32. <!--- reset the variable and show the use of CFABORT --->
  33.  
  34. <H3>Example B: Use CFABORT to halt the instruction</H3>
  35.  
  36. <CFSET myVariable = 3>
  37. <!--- now, perform a loop that increments this value --->
  38. <CFLOOP FROM="1" TO="4" INDEX="Counter">
  39.     <!--- on the second time through the loop, CFABORT --->
  40.     <CFIF Counter is 2>
  41.         <CFABORT>
  42.     <!--- the processing is stopped, and subsequent operations
  43.     are not carried out by the CFAS --->    
  44.     <CFELSE>
  45.     <CFSET myVariable = myVariable + 1>
  46.     </CFIF>    
  47. </CFLOOP>
  48.  
  49. <CFOUTPUT>
  50. <P>    The value of myVariable after incrementing through the loop
  51.     #counter# times is: #myVariable#
  52. </CFOUTPUT>
  53.  
  54. </P>
  55.  
  56. </BODY>
  57.  
  58. </HTML>       
  59.