AnsweredAssumed Answered

Problem with HiliteSingle custom function - what am I doing wrong?

Question asked by user23934 on Mar 29, 2016
Latest reply on Mar 30, 2016 by user23934

I posted this to an old thread ( Highlight Specific Words with Conditional Formatting) , but I think it would probably be better as a new question.


I'm trying to get my database to highlight the search words in my search results window. There are a few custom functions that seem to do this, but for the life of me I can't get them to work.


I've  tried both Michael Horak's HiliteSingle function from, and Fabrice's TextHighlightWithStyles function from, and I get the same problem - only the first instance of the search term is highlighted, then the rest of the text string is replaced by the search term itself!


It must be something I'm doing wrong, because I haven't seen anyone else raising this error, but I am at my wits end to know what it is. I've tested in both v14 and 11 - the behaviour is the same.



My Calc field definition: HiliteSingle( Get ( QuickFindText ); shotlist)

Shotlist field value (standard text field):

Int mcu Australian opposition leader MARK LATHAM iv sot

Ext walk LATHAM crossing road and entering studio sot

Int walk LATHAM entering studio sot

Int vs LATHAM iv sot


Quickfind: Latham

Calc Result:

Int mcu Australian opposition leader MARK LATHAMlatham


The result from the TextHighlightWithStyles is almost identical, but instead of the search term appearing, a number does!

Int mcu Australian opposition leader MARK LATHAM768

Can anyone shed any light on what on earth I'm doing wrong??


Thanks, Caitlin



Nb. This is Michael's function:


Let ( [


pos = Position ( text ; searchString ; 1 ; 1 )

] ;


Case ( pos ;


Let ( [

textBefore = Left ( text ; pos - 1 ) ;

len = Length ( searchString ) ;

string = Middle ( text ; pos ; len ) ;

textAfter = Right ( text ; Length ( text ) - pos - len + 1 )

] ;

textBefore & TextStyleAdd ( string ; HighlightYellow ) &HiliteSingle( textAfter;searchString)

) ;


text )



I tried replacing &HiliteSingle( textAfter;searchString) with just textAfter which confirmed that value is correct, but how to get the subsequent highlights to work?