4 Replies Latest reply on Sep 18, 2012 2:12 PM by HOnzaKoudelka

    NULL characters in fields cause problems

    HOnzaKoudelka

      Summary

      NULL characters in fields cause problems

      Product

      FileMaker Pro

      Version

      12v2

      Operating system version

      Mac OS X 10.6.8

      Description of the issue

      It is possible to paste text containing a null character to a field from clipboard.
      Such character then causes troubles because some functions do not expect strings to contain such characters.

      Examples:

      * the Code functions correctly returns 0 for such character
      * Char(0) returns an empty string
      * Evaluate(Quote(*text*)) freezes filemaker then *text* contains a null character

      Example demonstrating the bug is available at http://24usw.com/nullbug

      Steps to reproduce the problem

      1. Copy text containing a null character to clipboard (you can use TextWrangler for this)
      2. Paste the text into a field
      3. Try to use the text in calculations

      Expected result

      All calculations should work with the null character just like with any other character

      Actual result

      Some calculations cause problems, such as freezing, returning wrong results, etc.

      Workaround

      The only workaround I have been able to find is to use this custom function as auto-enter (or as custom menu item replacement for Paste) to correct the value when being pasted:

      StripNULLs(text) =
      Case(IsEmpty(text); ""; Char(Code(Left(text; 1))) & StripNULLs(Middle(text; 2; Length(text) - 1)))

        • 1. Re: NULL characters in fields cause problems
          philmodjunk

               As another workaround, have you tried using the Filter Function? Listing every acceptible character in the string of filter characters might get pretty obnoxious, but it might in many cases eliminate the need for the custom function.

          • 2. Re: NULL characters in fields cause problems
            HOnzaKoudelka

                 I can imagine doing that when dealing with ASCII, but not with Unicode....

                 BTW, what is the benefit of not needing a custom function (except for the case you want to use FileMaker Pro instead of FileMaker Pro Advanced for development)?

                 OK, there are other workarounds possible, such as pasting the null character into a global field and then using Substitute to replace every occurrence of null character in text with an empty string.

                 The point is that any workaround requires somehow modifying every text being pasted...

                  
            • 3. Re: NULL characters in fields cause problems
              philmodjunk

                   Not all people reading this thread may have FileMaker Advanced. Offering an alternative work around that does not require a custom function would be useful to them. I would also be interested in seeing the definition for the custom function that you are using.

                   For any of these methods, I'd use auto-enter calculations set directly on the text fields whenever possible. Your example of using a substitute function is one such expression that could work as an auto-enter calculation.

                   Please note that I'm not trying to suggest that this isn't a bug that needs to be fixed, just exploring workaround options that may be of use to those who encounter this issue.

              • 4. Re: NULL characters in fields cause problems
                HOnzaKoudelka

                     You're right about the audience of this forum.

                     I am assuming (maybe incorrectly) that not many people who don't have Advanced will be really affected by this bug ;-)

                     BTW, I have included my custom function definition at the end my original post.