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 / exampleapps / email / wrap.cfm < prev   
Encoding:
Text File  |  2001-06-13  |  1.5 KB  |  57 lines

  1. <CFSETTING ENABLECFOUTPUTONLY="YES">
  2.  
  3.  
  4. <!--- Initialize variables --->
  5.  
  6. <CFPARAM NAME="Attributes.BreakChars" DEFAULT=" -">
  7. <CFSET BreakChars = Attributes.BreakChars>
  8.  
  9. <CFPARAM NAME="Attributes.Width" DEFAULT="80">
  10. <CFSET Width = Attributes.Width>
  11.  
  12. <CFSET Newline = Chr(10)>
  13.  
  14. <CFSET Wrapped = "">
  15.  
  16. <CFSET Remaining =  evaluate("Caller." & Attributes.Variable)>
  17.  
  18.  
  19.  
  20. <!--- Loop until there are fewer than #WIDTH# characters left --->
  21.  
  22. <CFLOOP CONDITION="Len(Remaining) GT Width">
  23.  
  24.     <CFSET CurrentLine = Left(Remaining, Width)>
  25.     <CFSET Remaining = Right(Remaining, Len(Remaining) - Width)>
  26.  
  27.     
  28.     <CFIF Find(Newline, CurrentLine) NEQ 0>
  29.         <CFSET Pos = Find(Newline, CurrentLine)>
  30.         <CFSET Wrapped = Wrapped & Left(CurrentLine, Pos)>
  31.         <CFIF Pos NEQ Len(CurrentLine)>
  32.             <CFSET Remaining = Right(CurrentLine, Len(CurrentLine) - Pos) & Remaining>
  33.         </CFIF>
  34.  
  35.     <CFELSEIF FindOneOf(BreakChars, CurrentLine) NEQ 0>
  36.         <CFSET CurrentLine = Reverse(CurrentLine)>
  37.         <CFSET Pos = FindOneOf(BreakChars, CurrentLine)>
  38.         <CFSET CurrentLine = Reverse(CurrentLine)>
  39.         <CFSET Pos = Len(CurrentLine) - Pos + 1>
  40.  
  41.         <CFSET Wrapped = Wrapped & Left(CurrentLine, Pos) & Newline>
  42.         <CFIF Pos NEQ Len(CurrentLine)>
  43.             <CFSET Remaining = Right(CurrentLine, Len(CurrentLine) - Pos) & Remaining>
  44.         </CFIF>
  45.  
  46.     <CFELSE>
  47.         <CFSET Wrapped = Wrapped & CurrentLine & Newline>
  48.  
  49.     </CFIF>
  50.  
  51. </CFLOOP>
  52.  
  53. <CFSET Wrapped = Wrapped & Remaining>
  54.  
  55. <CFSET "Caller.#Attributes.Variable#" = Wrapped>
  56.  
  57. <CFSETTING ENABLECFOUTPUTONLY="NO">