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 http://www.briandunning.com/cf/578, and Fabrice's TextHighlightWithStyles function from http://www.fmfunctions.com/functions_display_record.php?functionId=268, 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
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??
Nb. This is Michael's function:
Let ( [
// TEST FOR MATCH
pos = Position ( text ; searchString ; 1 ; 1 )
// IF MATCH IS FOUND
Case ( pos ;
// BEGIN CALCULATION
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)
// ELSE RETURN 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?