Brian Dunning's FileMaker Custom Functions

hlSection ( theText ; Values ; Red ; Green ; Blue ; Style )

Highlight everything between specified words with Text Color and Styles

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

Matt Wills   Matt Wills - Show more from this author
Virtual Vermont
http://www.virtualvermont.com/FMP/

Share on Facebook Share on Twitter

  Sample input:
Where theText is:

When, in the Course of human Events, it becomes necessary for one People to dissolve the Political bands, which have connected them with another...

and you want to make everything between "dissolve" and "bands" appear bolded and underlined in red, the CF would be:

hlSection ( theText ; "dissolve¶bands" ; 255 ; 0 ; 0 ; Bold+Underline )
  Sample output:
When, in the Course of human Events, it becomes necessary for one People to dissolve the Political bands, which have connected them with another..."

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

Displays everything between two given words in a specified color and styles.

The words in the Values parameter are separated by a pilcrow (as would be values in a list).

 

Comments

Peter Vinogradov   Peter Vinogradov
Feb 14, 2011
Useful, thank you. I've created a recursive version that I'm using as a primitive color-coder for some XML:

-------------------
/* hlSection ( theText ; Values ; Red ; Green ; Blue ; Style ) */

Let ( [

StartWord = GetValue ( Values ; 1 ) ;
Start = Position ( theText ; StartWord ; 1 ; 1 ) ;
FinishWord = GetValue ( Values ; 2 ) ;
Finish = Position ( theText ; FinishWord ; Start ; 1 ) + Length ( FinishWord ) ;
Pre = Left ( theText ; Start -1 ) ;
Phrase = TextColor ( Middle ( theText ; Start ; Finish - Start ) ; RGB ( Red ; Green ; Blue ) ) ;
Post = Right ( theText ; Length ( theText ) - Finish + 1);
More = PatternCount ( Filter ( Post ; StartWord & FinishWord) ; StartWord & FinishWord)

] ;

Pre &

If (not IsEmpty (Style) ; TextStyleAdd ( Phrase ; Style ) ; Phrase ) &

If ( More ; hlSection ( post ; Values ; Red ; Green ; Blue ; Style ) ;
Post
)

)
-------------
 
gopal patel   gopal patel, Dr Patels Clinic
Jul 24, 2021
@ Peter Vinogradov for the recursive version I tried
hlSection ( text ;"¶" ; 255 ; 21 ; 21 ; Italic ) but the section has multiple but it only does for the 1st any thing I am missing?
 

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.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: