2 Replies Latest reply on Feb 24, 2015 7:45 PM by philmodjunk

    Script to change text color based on "found" word



      Script to change text color based on "found" word


      I need to be able to search in all document fields to find the word "Needed", and then change that word to red text. Anybody got a script or a method for something like that?


        • 1. Re: Script to change text color based on "found" word

          Kelly Carlson-Reddig:

          Thank you for your post.

          One method would be to use a global storage field, take the contents and search the database.  Here is a sample script that will search one text field.

          1. Create a Text field, "Global", set to use global storage.

          2. Create a script, "Search" with the following script steps:

             Set Error Capture [ On ]
             Set Variable [ $search ; Value: Global ]
             Enter Find Mode [ ]
             Set Field [ <text field to search> ; $search ]
             Perform Find [ ]
             If [ Get ( FoundCount ) > 0 ]
                Replace Field Contents [ No dialog ; <text field> ; Substitute ( <text field> ; $search TextColor ( $search ; RGB (255;0;0) ) )
             End If


          In essence, I entered the information into the global field, captured that information to a variable, searched for records that contained that value in the text field, and if any records are found, I replaced the contents of the field substituting the normal text color of the field with red color of the word.

          Create additional script to remove the text color (TextColorRemove function) when finished.

          Let me know if you need additional clarification.

          FileMaker, Inc.

          • 2. Re: Script to change text color based on "found" word

            Hmmm, but if Global has global storage, you don't need the variable. Your set field step can be:

            Set field [<text field to search> ; Global ]

            And while using this text to find records will not be case sensitive, Substitute, regrettably for this use of substitute, is case sensitive. So this search can find a record with matching text that then is not formatted to turn red. You could, however, use brackets with the substitute function to match using all the common possible capitalizations of your search text such as no caps, all caps and first letter capped.