4 Replies Latest reply on Dec 26, 2012 12:47 PM by MalcolmTodd

    Highlighting 'found' word

    MalcolmTodd

      Title

      Highlighting 'found' word

      Post

           I am building a book review database using FM Pro 11. One of the text fields I use is "review" which contains the complete review; I use Find mode to enter a word  which may occur in any of the records "review" field. My script then uses Perform Find to bring up all the results,  which contain complete reviews. I now want occurences of the initially input word  to appear highlighted within the output result(s). Obviously the input word appears in different places in different records.

           How may I achieve this?  Many thanks for any suggestions.

        • 1. Re: Highlighting 'found' word
          philmodjunk

               Does the text in the review field need to be editable?

               Do you have FileMaker Pro Advanced?

          • 2. Re: Highlighting 'found' word
            MalcolmTodd

                 The text  in the review field does not need to be edited.

                 I do not have FileMaker Pro Advanced; just the basic FM Pro 11.

                 Thanks.

            • 3. Re: Highlighting 'found' word
              philmodjunk

                   With Advanced you can add a custom function to your file that can highlight every instance of a record in a field by giving it a distinctive text style. Without advanced, a looping script can do the same.

                   Set up a scripted find for this where the user enters or selects the word in a global text field and then clicks a button to perform a script to find records containing that text: Scripted Find Examples

                   Then set up a looping script:

                   Set vairable [$Occurrences ; value: PatternCount ( YouTable::Review ) ]
                   Set variable [$L ; value: Length ( Globals::gSearchText ) //This is your global search field used in the find script]
                   Set Variable [$Lrev ; value: Length ( YourTable::Review ) ]
                   Loop
                      Set Variable [$K ; $K + 1 ]
                      Exit Loop If [ $K > $Occurrences ]
                      SetField [ $Start ; value: Position ( YourTable::Review ; 1 ; $K ) ]
                      Set Field [YourTable::Review ;
                                Left ( YourTable::Review ; $LeftText ) & TextColor ( Middle ( YourTable::Review ; $Start ; $L ) ; RGB ( 255 ; 0 ; 0 ) ) &
                                Right ( YourTable::Review ; $Lrev - $Start - $L ) ]
                   End Loop

                   Notes:

                     
              1.           This script has not been tested so adjustments may be needed--especiall in the set field calculation.
              2.      
              3.           It may occur to you that Substitute could be used for this purpose, but substitute is case sensitive--making it difficult to match to all possible capitalizations of the search text.
              4.      
              5.           TextColorRemove can be used to clear the red text out before the user performs a new find to find records using different search text.
              • 4. Re: Highlighting 'found' word
                MalcolmTodd

                     Many thanks. I'll try that and let you know the outcome.