1 Reply Latest reply on Jul 28, 2010 9:00 AM by philmodjunk

    conditional formatting to highlight matching text

    trialuser1111

      Title

      conditional formatting to highlight matching text

      Post

      We have recently upgraded to FMP11 here and I am trying to boost the value of our search functionality by having specific words highlighted in a passage of text.  There is a global search field that people type keyword(s) into, and I would like to have those word(s) highlighted in a text block.  I am trying to implement this solution in various portions of my database; in some cases it is a standard text field, but in others it is just unassigned text.  Is the solution the same?

        • 1. Re: conditional formatting to highlight matching text
          philmodjunk

          Conditional formatting applies a format to the entire layout object, whether that be a field or a block of layout text (that what you mean by "unassigned text"?) Therefore you can't use a conditional format to highlight selected text within the object.

          You may be able to use Find/Replace in a script to "find" and then Highlight selected text in a text field, but this won't work for Layout text objects and it will only find the first such instance and highlight it, not all of them.

          A calculation field using substitute can be used to subsitute formatted text in your field for matching unformatted text. This can mark selected text with a different color or make it bold face or italics, but substitute is case sensitive--so that complicates the approach as well.

          A calculation field that returns text like the following may work:

          Subsitute ( TextField ; [Upper ( Matchtext ) ; Upper ( TextStyleAdd ( MatchText ; Bold ) ) ] ; 
                                             [ Proper ( Matchtext ) ; Proper ( TextStyleAdd ( MatchText ; Bold ) ) ] ;
                                             [ Lower ( MatchText ) ; Lower ( TextStyleAdd ( MatchText ; Bold ) ) ] ; 
                                             [matchText ; TextStyleAdd ( MatchText ; Bold ) ) ] )

          This isn't perfect as "ADb" won't cause "adb" to be shown in bold face though most conventional capitalizations will be shown in bold face.