Brian Dunning's FileMaker Custom Functions

HiliteMulti ( text ; searchValues ; color )

Returns text with every occurrence of each value in searchValues in text changed to the specified color.

  Average rating: 4.5 (40 votes) Log in to vote

Michael Horak   Michael Horak - Show more from this author
*COMMENT Visual Realisation

Share on Facebook Share on Twitter

  Sample input:
HiliteMulti (
"Dogs, horses and cats" ;
"dog¶CAT" ;
RGB (255;0;0)
)
  Sample output:
{Dog}s, horses and {cat}s

(the strings in curly braces are in red color)

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

Returns text with every occurrence of each value in searchValues in text changed to the specified color.

The searchValues parameter accepts a list of multiple values, separated by carriage returns.

Requires the HiliteSingle() custom function.

The HiliteMulti() function is NOT case-sensitive. Occurrences of searchValues are matched regardless of case, and returned in their original case.

 

Comments

Daan Van den Nest   Daan Van den Nest, Ghent, Belgium
Mar 22, 2009
Doesn't work: none of the values are highlighted... Is this a known issue?

Thanks

Daan
 
gs   gs, ha noi
Jan 15, 2010
ok
 
Brian   Brian, Louisville
Jul 15, 2011
I like it.
 
Tiago   Tiago, Antwerp
Aug 11, 2011
Good Function, just what I was looking for.
 
Stefano   Stefano, Screen srl
Apr 5, 2013
Very good function! Thanks a lot.
 
Chris CoZi   Chris CoZi, Rutland, VT
Aug 13, 2014
/*
HiliteMulti function
Updated to allow multiple color entries.

Author
*COMMENT Visual Realisation

Format
HiliteMulti ( text ; searchValues ; colors )

Parameters
text - any text expression or text field;
searchValues - any text expression or text field;
colors - any integer number from 0 to 16777215 or RGB value.

Data type returned
text

Description
Returns text with every occurrence of each value in searchValues in text changed to the specified color.
The searchValues parameter accepts a list of multiple values, separated by carriage returns.
The colors parameter accepts a corresponding list of multiple values.
NOTE: Color values are entered as non-text entries formatted as example: RGB (0;0;0) & ¶ & RGB (255;255;255)

Requires the HiliteSingle() custom function.
The HiliteMulti() function is NOT case-sensitive. Occurrences of searchValues are matched regardless of case, and returned in their original case.

Updated August 12, 2014
*/


Let ( [
searchString = Substitute ( LeftValues ( searchValues ; 1 ) ; ¶ ; "" ) ;
replaceColor = Substitute ( LeftValues ( colors ; 1 ) ; ¶ ; "" ) ;
newText = HiliteSingle ( text; searchString; replaceColor )

] ;
Case (
ValueCount ( searchValues ) > 1 ;
HiliteMulti ( newText ; RightValues ( searchValues ; ValueCount ( searchValues ) - 1 ) ; RightValues ( colors ; ValueCount ( colors ) - 1 ) ) ;
newText
)
)
 
Laura   Laura
Oct 27, 2017
The comment did not post properly, so here is the edit:
The updated code for multiple colors is giving error "There are too many parameters in this function". I have defined the function variables "text", "searchValues", and "colors", but this does not seem to be the problem.
 

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: