Viewing Individual Entry / Main
  ::   August 7, 2003

Wrapping with Wrap() in CF MX 6.1
I saw a question on the CF-Talk list asking about the new wrap() function in CF MX 6.1. It's not as intuitive a function as you would think. The first time I saw it, I assumed you passed it a string and a character break, and it would return a string formatted with
tags at the appropriate interval. This is not what it does. Here's an explanation from my new book, Programming ColdFusion MX:

Usage: wrap(string, limit [,strip])

Specifies the maximum number of characters to allow per line in string. If a line is longer than the specified number of characters, an attempt is made to break the line by inserting a line break at the nearest whitespace character (space, tab, etc) before the character limit. If string contains no whitespace characters before the maximum number of characters per line, a line break is inserted at the maximum line length. Wrap() uses operating system specific line breaks. On Windows, it's a carriage return and newline character. On Unix/Linux, it's a newline. Optionally, you can specify a third Boolean argument to indicate whether to remove all existing carriage line breaks before wrapping the string. The default for this argument is false.


#wrap(myString, 80, False)#

If you need a function that actually inserts
tags for you, consider wrap() from the CFLib.org web site. Note that you'll have to rename the UDF to avoid conflicting with the new wrap() function in 6.1.



Calendar
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

Recommended Reading
The Cuisine of Hubert Keller

Archives by Subject
Announcements (28)
ColdFusion (61)
Database (12)
Dreamweaver (1)
Flash (2)
Flash Remoting (2)
Flex (3)
General Development (2)
Homesite + (1)
Mach-II (3)
MAX (9)
Mozilla (2)
Music (1)
Politics (1)
Portals (2)
Travel (2)

Search

Links
CFLib.org
Raymond Camden's Blog
Christian Cantrell's Blog
Sean Corfield's Blog
Nathan Dintenfass' Blog
Todd Rafferty's Blog
Steve Rittler's Blog
Cameron Childress's Blog

Credits
Based on blog.cfc by Raymond Camden

XML Feed