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
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
)

)
-------------
 

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.