home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfabort.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.3 KB  |  58 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. <BODY bgcolor=FFFFFF>
  13.  
  14. <H1>CFABORT Example</H1>
  15.  
  16. <P>
  17. <H3>Example A: Let the instruction complete itself</H3>
  18. <!--- first, set a variable  --->
  19. <CFSET myVariable = 3>
  20. <!--- now, perform a loop that increments this value --->
  21. <CFLOOP FROM="1" TO="4" INDEX="Counter">
  22.     <CFSET myVariable = myVariable + 1>
  23. </CFLOOP>
  24.  
  25. <CFOUTPUT>
  26. <P>    The value of myVariable after incrementing through the loop
  27.     #Counter# times is: #myVariable#
  28. </CFOUTPUT>
  29.  
  30.  
  31. <!--- reset the variable and show the use of CFABORT --->
  32.  
  33. <H3>Example B: Use CFABORT to halt the instruction</H3>
  34.  
  35. <CFSET myVariable = 3>
  36. <!--- now, perform a loop that increments this value --->
  37. <CFLOOP FROM="1" TO="4" INDEX="Counter">
  38.     <!--- on the second time through the loop, CFABORT --->
  39.     <CFIF Counter is 2>
  40.         <CFABORT>
  41.     <!--- the processing is stopped, and subsequent operations
  42.     are not carried out by the CFAS --->    
  43.     <CFELSE>
  44.     <CFSET myVariable = myVariable + 1>
  45.     </CFIF>    
  46. </CFLOOP>
  47.  
  48. <CFOUTPUT>
  49. <P>    The value of myVariable after incrementing through the loop
  50.     #counter# times is: #myVariable#
  51. </CFOUTPUT>
  52.  
  53. </P>
  54.  
  55. </BODY>
  56.  
  57. </HTML>       
  58.