1 2 3 Previous Next 33 Replies Latest reply on Jul 25, 2009 12:37 PM by comment_1

    Find/highlight within a text field

    CarrieB.

      Title

      Find/highlight within a text field

      Post

      I was wondering if it is possible to find within a specific field of a record? For example, I have a notes field that can get rather lengthy and when someone runs a search for keywords, it would be nice to see where that keyword is in the field. 

       

      Any feedback is much appreciated! 

        • 1. Re: Find/highlight within a text field
          philmodjunk
            

          Well kinda, sorta, but with some limitations.

           

          You can use

           

          Set Selection [Start Position: <n>; End Position: <n>]

           

          To select and highlight a specific section of a text field. This will not enable you to highlight multiple instances of a keyword and if the field is editable, your user is now one key stroke away from changing the contents of the highlighted text.

           

          You can use

           

          Substitute(textfield;keyword;TextStyleAdd(keyword;Bold))

           

          In a calculation field

           

          To show every instance of Keyword in textfield as Bold, but it is unfortunately case sensitive. Which means that

           

          Substitute(textfield;"apple";TextStyleAdd("apple";Bold))

           

          will show apple in bold face throughout the text field, but "APPLE" and "Apple" will not be shown in bold.

          • 2. Re: Find/highlight within a text field
            raybaudi
              

            CarrieB. wrote:

             

            I was wondering if it is possible to find within a specific field of a record


            Hi

             

            give a look to the Edit >> Find/Replace menu command.

             

            It can be full customised and even scripted.

            • 3. Re: Find/highlight within a text field
              comment_1
                

              I believe Perform Find/Replace[] would be your best option.

               

              Highlighting, though possible*, is problematic because it requires a calculation. You would either need to modify the contents of the field, or display the highlighting in another field.

               

               

              ---

              (*) See:

              http://www.briandunning.com/cf/578

              http://www.briandunning.com/cf/579

              • 4. Re: Find/highlight within a text field
                CarrieB.
                   Wow. It must have been a really long time since I have worked in FileMaker. I cannot figure out the simplest of things! I am trying to write a script that will allow users to perform the find/replace, but I can't get it to work. I've scripted it to go to the specific field, then perform find/replace, but it doesn't work. What am I missing? Other there other parameters that need to be in the script? It seems so simple .....
                • 5. Re: Find/highlight within a text field
                  philmodjunk
                     I've been researching this after the other posts came up. Try Open Find/Replace.
                  • 6. Re: Find/highlight within a text field
                    comment_1
                       How would you like your users to specify what to find?
                    • 7. Re: Find/highlight within a text field
                      CarrieB.
                        

                      I think the Open Find/Replace will work just find. I will just have to train the users to make sure they choose the proper options.

                       

                      Thanks! 

                      • 8. Re: Find/highlight within a text field
                        raybaudi
                          

                        "I will just have to train the users to make sure they choose the proper options."

                         

                        That isn't the correct way to go on...

                         

                        Let say that you have:
                        1) a text field ( Text ) that contains the text to be searched
                        2 ) another text field ( Find ) where the user insert by hand the text to search

                         

                        try this:

                        1) Into the auto-enter option for the field "Text" insert this calculation:

                         

                        TextColorRemove ( Text )

                         

                        2) write down this script ( FindAll ):

                         

                        Go to field [ YourTable:: Text ]
                        Perform Find/Replace [ No dialog ; Perform: Replace All ; Find what: YourTable:: Find ; Replace with: "§§§" ; Direction: All ; Match case ; Search across: Current record ; Search within: Current field ]
                        Insert Calculated Result [ Select ; YourTable:: Text ; Substitute ( YourTable:: Text; "§§§" ; TextColor ( YourTable:: Find ; RGB ( 255 ; 0 ; 0 ) ) ) ]

                         

                        3) Attach that script to a button.

                         

                        The result will be:

                         

                        a) the user enters a word to search into the "Find" field
                        b) press the button
                        c) the field "Text" will show the searched word in red color ( and still have the focus )
                        d) exiting the field, it will revert to its previous status.

                        • 9. Re: Find/highlight within a text field
                          comment_1
                             And if two users are trying to do this in the same record?
                          • 10. Re: Find/highlight within a text field
                            raybaudi
                              

                            I do not know if there will be problems.

                             

                            I haven't much experience with multi-user scenario.

                             

                            There isn't a record locking ?

                            • 11. Re: Find/highlight within a text field
                              comment_1
                                

                              raybaudi wrote:

                              There isn't a record looking ?


                              Of course there is, if you're modifying the field contents. What's worse, after you commit the record, the last user's search phrase will be highlighted for all users.


                              • 12. Re: Find/highlight within a text field
                                raybaudi
                                  

                                comment wrote:

                                 

                                What's worse, after you commit the record, the last user's search phrase will be highlighted for all users.


                                But committing the record do not fires the evaluation of the auto-enter calc ?

                                 

                                IOW, the other users will be able to access the record ONLY after the committing ( and the consequent retrieval of the pre-situation ).

                                 

                                Do not ?

                                • 13. Re: Find/highlight within a text field
                                  comment_1
                                    

                                  CarrieB. wrote:

                                  I will just have to train the users to make sure they choose the proper options.


                                  Good luck with that…

                                   

                                  I'd do it this way (given a Content field to search and a global gSearchPhrase field containing the search phrase):

                                   

                                  If [ IsEmpty ( Get ( ActiveFieldName ) ) ]
                                  Set Selection [ Table::Content; Start Position: 0; End Position: 0 ]
                                  End If
                                  #
                                  Perform Find/Replace [
                                  Find: Table::gSearchPhrase;
                                  Search operation: Find Next;
                                  Search settings: All;
                                  Search across: Current record/request;
                                  Search within: Current field ]
                                  [ No dialog ]

                                   





                                  • 14. Re: Find/highlight within a text field
                                    comment_1
                                      

                                    raybaudi wrote:

                                     IOW, the other users will be able to access the record ONLY after the committing 


                                    Yes, that's correct. So the "only" problem is that while one user is viewing the highlights, the record is locked.


                                    1 2 3 Previous Next