WordWrap ( Text ; Size )
Rate this function: Average rating: 3.4 (21 votes) Discuss this Custom Function
Jonathan Stark, Jonathan Stark Consulting
http://jonathanstark.com/
Wraps text to specified max line character count, without breaking words
Sample Input:
| This is a really long text string that I need to display narrowly in a huge text field. Or some other weird reason like that. |
|
Sample Output:
This is a
really long
text string
that I need
to display
narrowly in a
huge text
field. Or
some other
weird reason
like that. |
|
Description:
Wraps text to specified max line character count, without breaking words. I used this function for compiling invoices as text for output as email, like so:
<pre>
Qty Description Price
=======================================
3 Here is the long $34.00
item description
that I needed to
wrap.
---------------------------------------
2 Next item $37.00
---------------------------------------
2 Next item $37.00
=======================================
</pre>
UPDATE:
Thank you to all the folks who emailed me about the "question mark" result (undefined result).
Yes, I am aware of the question mark. But, I feel that is appropriate for the function to return "undefined" because you are asking to do something impossible. IOW - the function can't wrap a line to 10 characters without breaking a word, if there is a word on that line that is 12 characters long.
HTH,
j
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
edit it
Discuss:Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
|
Newest Custom Functions:
| 1. |
list.intersect (listA; listB) |
| |
(Mon, May 14, 12:43pm) |
| 2. |
WeekStart ( weekOfYear ; year ) |
| |
(Sat, May 12, 8:42am) |
| 3. |
PercentToWords (FIELD) |
| |
(Thu, May 10, 3:16pm) |
| 4. |
PercentToText (FIELD) |
| |
(Thu, May 10, 2:37pm) |
| 5. |
StripReserved( text ) |
| |
(Wed, May 02, 6:05pm) |
| 6. |
ListBaseTables |
| |
(Wed, May 02, 3:48pm) |
| 7. |
ValidEmail( theEmail ) |
| |
(Wed, May 02, 7:27am) |
| 8. |
UltraDate (Text; LongDate_or_DateDigit) |
| |
(Wed, May 02, 6:07am) |
 |
|
I would like to truncate with an ellipsis rather than wrap text, when the text length exceeds the portal size. Can you help?
Anthony, Philadelphia
January 29, 2011 5:04pm