7 Replies Latest reply on Feb 24, 2011 3:17 PM by CarlJones

    Bold and Highlighting in text fields



      Bold and Highlighting in text fields


      I am quite new to filemaker. I am trying to use the conditional formatting to highlight specific workds in a text field that will have several complete paragraphs in it. I want to highlight them simply for reader awareness. I have tried using the conditional formatting. The value formatting wants to highlight the entire paragraph when I use the following "shall". It sees the shall word and highlights the entire paragraph. Then I tried using the formula TextStyleAdd which seem like it would be perfect. I cannot get this to work in the original text field. I am very new to this. Can someone please help me with this issue. Thanks

      Carl Jones

        • 1. Re: Bold and Highlighting in text fields

          Conditional formatting can only be used to apply formats to the entire layout object. It can't be used to apply formatting to just a part of the object such as a selected word within the text field.

          Perform Find/Replace can be used to highlight the first instance of the word, but I don't see an option that will highlight all instances of the word.

          It is possible to create a looping script, recursive custom function (requires FileMaker Advanced to create), or a recursive calculation that will highlight all instances of a selected word in a text field.

          • 2. Re: Bold and Highlighting in text fields

            Thanks. I have struggled three days with this. I am thinking of purchasing Filemaker Advanced. I want to work with documentation that is already created, in Work, PDF, and Excel. I want to pull th information into filemaker and break it up into sections. I hope this program will work for me. Thanks for the help...

            • 3. Re: Bold and Highlighting in text fields

              FileMaker should be able to do this and comes with a fairly decent set of text functions that may help you accomplish this. FileMaker advanced offers three very valuable features not found in regular FileMaker: The ability to create custom functions such as a recursive "highlight text" function, A script debugger with data viewer that can save one hours of frustration when a scritp doesn't perform as expected and Database Design Reports that can be searched and analyzed for problems due to "broken" references to scripts, fields, tables etc.

              • 4. Re: Bold and Highlighting in text fields

                Here's a custom function for applying a user specified style to every instance of a word in a block of text:

                // WordHighlight ( Paragraph ; Word ; style )
                // Returns text in Paragraph with every instance of Word having the style specified in style applied to it.
                Let ( [ TheWord = LeftWords ( Paragraph ; 1 ) ;
                        StartText = Left ( Paragraph ; Position ( Paragraph ; TheWord ; 1 ; 1 ) + Length ( TheWord ) ) ;
                        RemainText = Right ( Paragraph ; Length ( Paragraph ) - Length ( StartText ) ) ] ;
                         Case ( IsEmpty ( Paragraph ) ; Paragraph ;
                                    TheWord = Word ; TextStyleAdd ( StartText ; style ) & WordHighlight ( RemainText  ; Word ; style ) ;
                                    /* else */ StartText & WordHighlight ( RemainText  ; Word ; style )
                                  ) // case
                      ) // let

                Here's a looping script that does much the same thing: It places the styled text in a separate field so you can compare the original to the styled text, but a small change in the last line would make it apply the style to original field, though in that case you might want to add a step to apply textformatRemove to this field first if you don't want repeated runs of this script to leave text bolded by a previous run still in bold face.

                Set Variable [ $I; Value:1 ]
                       Set Variable [ $Word; Value:$Word + 1 ]
                       If [ MiddleWords ( WordHighlighter::Paragraph ; $Word ; 1 ) = WordHighlighter::Word ]
                               Set Variable [ $Paragraph;
                                                 Value:$Paragraph & TextStyleAdd ( Middle ( WordHighlighter::Paragraph; 
                                                 $I ; Position ( WordHighlighter::Paragraph ; WordHighlighter::Word ; $I ; 1 ) + Length ( WordHighlighter::Word ) - $I + 1 ) ; Bold ) ]
                               Set Variable [ $Paragraph; Value:Let ( word = MiddleWords ( WordHighlighter::Paragraph ; $Word ; 1 ) ; $Paragraph & 
                                                   Middle ( WordHighlighter::Paragraph; $I ; Position ( WordHighlighter::Paragraph ; word ; $I ; 1 ) + Length ( Word ) - $I + 1 ) ) ]
                       End If
                       Set Variable [ $I; Value:Let ( word = MiddleWords ( WordHighlighter::Paragraph ; $Word ; 1 ) ; 
                                           Position ( WordHighlighter::Paragraph ; Word ; $I ; 1 ) + Length ( Word ) ) + 1 ]
                       Exit Loop If [ $Word ≥ WordCount ( WordHighlighter::Paragraph ) ]
                End Loop
                Set Field [ WordHighlighter::Paragraph 2; $Paragraph ]

                • 5. Re: Bold and Highlighting in text fields

                  Thanks a million for the scripts... Will I be able to use these in FMP or do I have to have FMP Advanced... This is great. I did not expect this kind of help. Thanks again.... I am assuming you name is Phil!!!

                  • 6. Re: Bold and Highlighting in text fields

                    The looping script will work with any version--that's why I included it.

                    The custom function requires FileMaker Advanced to install. (You can use a custom function with regular FileMaker once you've used advanced to either create or import it.) If you have advanced, the custom function will save you set up time as you can copy and paste the text from my post into your custom function dialog.

                    • 7. Re: Bold and Highlighting in text fields

                      I just purchased FMP Advanced.... Thanks