3 Replies Latest reply on May 30, 2016 4:42 PM by scubatel

    TextStyleRemove not behaving as expected

    scubatel

      I am developing a taxonomic database that requires that species names be in italic text, with some exceptions.  Words such as sp., spp., cf. and aff. are not strictly taxonomic terms and should be in plain text.  I have used TextStyleAdd to format the entire field to Italic and then attempted to use the Substitute function along with TextStyleRemove to revert the selected words above to Plain text.  However, the script had no effect but, when I changed the TextStyleRemove statement to TextStyleAdd I was able to format the selected words to a style such as Bold (still retaining their Italic style as well).

       

      I finally found a work-around by nesting two TextStyleAdd functions, the first setiting the style to Bold and then to Plain and this removed both the Bold and the Italic formatting.  See below:

       

      Set Field [TextStyleAdd ( Get(ActiveFieldContents) ; Italic )]

       

      Set Field [Substitute ( Get(ActiveFieldContents) ;

      ["sp." ; TextStyleAdd (TextStyleAdd ( "sp." ; Bold ); Plain)];

      ["spp." ; TextStyleAdd (TextStyleAdd ( "spp." ; Bold ); Plain)];

      ["cf." ; TextStyleAdd (TextStyleAdd ( "cf." ; Bold ); Plain)];

      ["aff." ; TextStyleAdd (TextStyleAdd ( "aff." ; Bold ); Plain)]]

       

      This seems to be a rather convoluted approach to the problem.  Is there a bug in Filemaker Pro 15 or am I missing something?

        • 1. Re: TextStyleRemove not behaving as expected
          stephensexton

          The script does appear to be doubling up... did you try the following?

           

          Set Field [Substitute ( Get(ActiveFieldContents) ;

          ["sp." ; TextStyleAdd ( "sp." ; Plain)];

          ["spp." ; TextStyleAdd ("spp." ; Plain)];

          ["cf." ; TextStyleAdd ( "cf." ; Plain)];

          ["aff." ; TextStyleAdd ( "aff." ; Plain)])]

           

          .... or similar to the above, but using  ["sp." ; TextStyleRemove ("sp." ; AllStyles)]  etc.?

          • 2. Re: TextStyleRemove not behaving as expected
            scubatel

            Thanks for the feedback.  Yes, tried this but it did not have any impact.  Strange when you consider that replacing the formatting with Bold first and then with Plain works!  Also tried AllStyles and the TextStyleRemove options.  I was wondering if it was some sort of bug to do with formatting the whole field and then trying to reformat just one word. 

             

            Interestingly, I also tried reversing the process by formatting each of the words with Plain formatting and then formatting the whole field in Italic, just in case (by some weird logic) this worked. But it worked exactly as it should and formatted the whole field in Italics.

            • 3. Re: TextStyleRemove not behaving as expected
              scubatel

              In desperation, I rebooted the machine and retried the TextStyleAdd function with just the Plain formatting option - IT WORKED!  TextStyleRemove does still not work as it should and I am not sure why I had the initial problem.  But, who cares! (Until it resurfaces.)