7 Replies Latest reply on May 10, 2011 1:38 PM by philmodjunk

    Lists do not pass numeric validation test after GetAsNumber conversion

    philmodjunk

      Summary

      Lists do not pass numeric validation test after GetAsNumber conversion

      Product

      FileMaker Pro

      Version

      11.03

      Operating system version

      Windows XP SP3

      Description of the issue

      With validate always, and Numeric only specified for a field of type number the following script triggers a 502 validation error.

      While similar to the report at: http://forums.filemaker.com/posts/daabe4a9cf

      This appears to be different issue as this only seems to fail with a list of values. A single number in quotes does not trigger the validation error.

      Steps to reproduce the problem

      Set Error Capture [on]
      Set variable [$Number ; value: list ( 5 ; 4 ; 3 ) ]
      Set Field [Table::NumberField ; GetasNumber ( $Number ) ]
      Set Variable [$Error ; Value: get ( LastError ) ]
      Show Custom Dialog [$Error & ¶ & Quote ( GetAsNumber ( $Number ))]

      Expected result

      Error = 0
      "543"
      and 543 appears in numberfield

      Actual result

      502
      "543"

      No data is entered in field.

      Workaround

      As a work around, the following works and also suggests that the FileMaker team needs to look at the returns that separate values in a list to see where the problem lies:

      Set variable [$Number ; value: list ( 5 ; 4 ; 3 ) ]
      Set Field [Table::NumberField ; getValue ( GetasNumber ( $Number ) ; 1 ) ]

        • 1. Re: Lists do not pass numeric validation test after GetAsNumber conversion

          PhilModJunk:

          Thanks for posting!

          I was able to reproduce this behavior on both Windows and OS X. I went ahead and forwarded your post to our Quality Assurance and Development departments for review and confirmation. Thank you!

          TSBear
          FileMaker, Inc. 

          • 2. Re: Lists do not pass numeric validation test after GetAsNumber conversion
            davidhead

            Curiously, I am not getting this error on MacOS X 10.6.6 and FileMaker Pro Advanced 11.0v3.

            However, I also ask what is the requirement here? Why would one want to return a (text) list of numbers as a single number? This is trying to coerce text into a number. Is there a practical reason for wanting to do this?

            I would suggest that the thing that works - Set Field [Table::NumberField ; GetValue ( GetasNumber ( $Number ) ; 1 ) ] - is the more reasonable requirement to extract a specific number from a list.

            I am interested in the practical application of this requirement.

            TS_Oz, FileMaker Inc.

            • 3. Re: Lists do not pass numeric validation test after GetAsNumber conversion
              philmodjunk

              TS_Oz,

              Thanks for confirming that this bug does not exist on Snow Leopard. I'll update the Known Bug List entry accordingly.

              I agree it doesn't make any sense to actually do this under most circumstances. This is an issue I encountered by chance while trying to replicate a different issue that another poster reported.

              Nonsensical or not, (you never know when it might turn out to be needed under special circumstances), it is still a bug as it should not trip this validation error as shown by the result of the GetasNumber function call that's displayed inside the quotes in the custom dialog. Nor should you get different results on Mac and Windows systems.

              Set Field [Table::NumberField ; GetValue ( GetasNumber ( $Number ) ; 1 ) ]

              is exactly how I extract a single value from a list, but this is not what I am attempting here with this script. The script, as written, should concatenate numeric return separated values into a single number. The Set Field step should then be able to assign the value to a number field with numeric validation specified but it is not able to do so on a windows platform.

              Using getValue in the workaround was purely a test to see if that prevented the validation error and since it does, I included it as additional info that may prove useful.

              • 4. Re: Lists do not pass numeric validation test after GetAsNumber conversion
                davidhead

                Hi Phil

                Thanks for your follow-up.

                Given that the requirement and the result is somewhat "nonsensical" I don't know how many cycles should or will be spent on 'fixing' this behaviour. However, it may be useful to know and may point to some other behaviour that is broken. Thanks for posting the detail.

                Traditionally, FileMaker Pro has coerced data between types as a best guess as to what the user is trying to do. In many cases, we as FileMaker programmers probably assume a little too much and FileMaker Pro is a bit too accommodating for its own good. As you would know, in most programming languages, you need to be more explicit as to the type of data you are using and expect to be returned. Perhaps FileMaker Pro should be less accommodating and throw more errors when the user is trying to do something that is just wrong. Laughing But then that would go against the grain of FileMaker's in-built ease of use. Frown

                In this case, the 'right' way to do what you are expecting would be to strip the returns from the list and then set the field as a number. Since I can't test because I don't get the error in the first place, maybe you can test this:

                Set Variable [ $Number ; value: list ( 5 ; 4 ; 3 ) ]

                Set Field [ Table::NumberField; GetAsNumber ( Substitute ( $Number ; ¶ ; "" ) ) ]

                TS_Oz, FileMaker Inc.

                • 5. Re: Lists do not pass numeric validation test after GetAsNumber conversion
                  philmodjunk

                  Setting priorities for which bug should be fixed next isn't my job. I certainly wouldn't put it at the top of the list either, but any inconsistent behavior like this should be on the list somewheres.

                  IMO, your method is "a right way" not "the right way", but as expected, that expression does indeed work correctly on windows. GetasNumber is often used in unsual ways in FileMaker in order to remove nonnumerical data. Regardless of how "right" or "wrong" a particular use of it is, we should get predictable and identical results from both platforms.

                  Now the plot thickens. I decided on one more pair of tests:

                  I tried the following two scripts and was yet again suprised by the results as they reveal what appears to be a new inconsistency here:

                  Set Error Capture [on]
                  Set variable [$Number ; value: list ( 5 ; 4 ; "A" ; 3 ) ]
                  Set Field [Table::NumberField ; GetValue ( GetasNumber ( $Number ) ; 1 ) ]
                  Set Variable [$Error ; Value: get ( LastError ) ]
                  Show Custom Dialog [$Error & ¶ & Quote ( GetValue ( GetasNumber ( $Number ) ; 1 ))]

                  Enters 543 into the number field, "543" appears in the dialog, and a 0 error code is returned.

                  This script on the other hand:

                  Set Error Capture [on]
                  Set variable [$Number ; value: list ( 5 ; 4 ; "A" ; 3 ) ]
                  Set Field [Table::NumberField ; GetAsNumber ( Substitute ( $number ; ¶ ; "" ) ) ]
                  Set Variable [$Error ; Value: get ( LastError ) ]
                  Show Custom Dialog [$Error & ¶ & Quote ( GetAsNumber ( Substitute ( $number ; ¶ ; "" ) ))]
                  Returns a 502 error even though "543" appears in the dialog.
                  Note that this uses your "right way" to strip out the returns, but it fails to pass validation even though the value displayed in the custom dialog appears to be numeric and correct.
                  "But then that would go against the grain of FileMaker's in-built ease of use."
                  IMO, FileMaker's sloppy handling of data types does not really make it easier to use. Much more often, it makes it easier to mess up such as when a new user enters text into a number field and then discovers that a relationship based on it doesn't work as expected or a search or sort on the field produces unexpected results.
                  • 6. Re: Lists do not pass numeric validation test after GetAsNumber conversion
                    davidhead

                    Nor do I set priorities for which bugs get fixed next. I was making a comment on what I would expect. Yes it is inconsistent behaviour and I did thank you for reporting it.

                    Lots of functions and features in FileMaker are used in "unusual ways". This does not make them right or valid and often they are accidental behaviour and/or quite wrong.

                    I think your examples go too far down a path without a valid use case. But they may be helpful in determining exactly what FileMaker is doing with the various results.

                    TS_Oz, FileMaker Inc.

                    • 7. Re: Lists do not pass numeric validation test after GetAsNumber conversion
                      philmodjunk

                      Yes, but how decides what is the "right" way to construct an expression? I don't think that's part of your job description either. Wink

                      All I'm pointing out is that "right" or "wrong", both platforms should produce consistent results or we developers end up wasting time when an expression that worked correctly before, fails simply because the file was moved to the other platform.

                      "I think your examples go too far down a path without a valid use case."

                      That really misses the point. My examples were strictly intended to document the inconsistent behavior here--not to make a case for whether or not they should be used in that fashion.

                      Neither you nor I can predict how others will use the functions defined in FileMaker. Neither you nor I are the final arbiters of the 'right' way to use them in FileMaker. Using GetAsNumber to strip out non-numeric characters is a method I've seen used many, many times. If I or another developer choose to use that function, we should get consistent, predictable results--On Mac, Windows and iOS devices. Once such an inconsistency is identified and confirmed, it should be clearly documented by FileMaker so that we can easily research the issue if and when we encounter it.

                      So far, I've pointed out not one, but two such inconsistencies here. Can you confirm the results of my second apparent bug on the Mac platform?