Brian Dunning's FileMaker Custom Functions

Text_Wrap_Around ( Text ; limit_around )

Wraps text around specific number of characters, preserving manually set line breaks. Words usually stay complete.

  Average rating: 4.2 (20 votes) Log in to vote

Thomas Siebert   Thomas Siebert
http://www.t-seabird.de

Share on Facebook Share on Twitter

  Sample input:
Text_Wrap_Around ( "Why is six afraid of seven? Because 7 8 9." ; 12 )
  Sample output:
Why is six afraid
of seven? Because
7 8 9.

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Wraps text around specific number of characters.
manually set returns (¶) will be recognized correctly.
usually words remain complete.
if the limit is set very short words will be broken.
no problems with special characters found.
Text length is limited to ~10000 Lines.

 

Comments

Bernard Moreau   Bernard Moreau, Belgium
May 3, 2016
Looks nice, but specific number of chars "Line_Char_Limit" is not respected, even in your exemple output : "Why is six afraid" > 12 chars (I guess last word had to be trimmed ?).
BM
 
Thomas Siebert   Thomas Siebert
May 3, 2016
No, it is ment that words remain complete if they are inside the given limit.

You also may set the limit to 1 …

I also tried 0, it behaves different.
 
Bernard Moreau   Bernard Moreau, Belgium
May 3, 2016
Thanks Thomas for pointing out the "wrapping" limit I didn't read.

I got some problem with this splitting error :

Text_Wrap_Around ( "Very good job, I’m excited! but [I’m] may not be split." ; 17 ) --->

Very good job, I’
m excited! but [I’
m] may not be split.

Please advice.
 
Thomas Siebert   Thomas Siebert
May 4, 2016
Hi Bernard,

I rewrote the function completely and it is now shorter and more clear.

Now I get with your Text:

Text_Wrap_Around ( "Very good job, I’m excited! but [I’m] may not be split." ; 17 ) --->

"Very good job, I’m
excited! but [I’m]
may not be split. "
 
Bernard Moreau   Bernard Moreau, Belgium, Borchtlombeek
May 4, 2016
Hi Thomas,

For me, this is perfect.
I vote the maximum rate !

Thanks.

Bernard.
 
Thomas Siebert   Thomas Siebert
May 5, 2016
Error found:

if text ends with:
"Bernard Moreau, Belgium
May 03, 2016 3:34am"

… the last line will be missing.

but if works with a blank before "am" :

"Bernard Moreau, Belgium
May 03, 2016 3:34 am"
 
Bernard Moreau   Bernard Moreau, Belgium, Borchtlombeek
May 9, 2016
Indeed, this last new version is not stable :
- error you pointed out (line with "3:34am" missing)
- some errors with ¶ return in text
- not keeping the linespaces between 2 paragraphs ( = .¶¶ or more repeated ¶ returns)

Previous version (I fortunately keeped) didn't generated the first error and was nicely compact. Knowing it was not managing the '¶ return' in text, for me it was more convenient.
 
Thomas Siebert   Thomas Siebert
May 13, 2016
I have the function rewritten once again.
seems a lot better then the last version
and more flexible then the first stable version.
 
Bernard Moreau   Bernard Moreau, Belgium, Borchtlombeek
May 16, 2016
Much better, thank you.
Last remaining error, depending of the limit_around length, ¶ end of paragraph sometimes becomes ¶¶ (adds one line space).
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.