13 Replies Latest reply on Aug 6, 2014 3:43 PM by philmodjunk

    Is this a Bug?

    RichNasser

      Title

      Is this a Bug?

      Post

           Not sure if it's a bug, but I'll throw this out there before I submit to the issues page:

            

           see screenshot:  while stepping in with debug tool I come across two if-then statements. 

           The first if $NowAvailForRip <> 0 yields true and sends me to the second if-then:

           If $NumProdReq > $NowAvailForRip - when the statement is evaluated it reaches a TRUE and sends me into the if-then as you can see by the blue arrow -   but the values to the right in the watch window show $NumProdReq as 6 and $NowAvailForRip as 10 - how can 6 > 10 yield TRUE.

           Perhaps I have something wrong, but perhaps this is a bug

      bugfm.png

        • 1. Re: Is this a Bug?
          raybaudi

               "how can 6 > 10 yield TRUE"

               That is true when you didn't declare the $var as a number; Filemaker ALWAYS interpret an $var as TEXT.

               Try to set the $var = GetAsNumber ( YourNumber )

                

          • 2. Re: Is this a Bug?
            RichNasser
                 

            "Filemaker ALWAYS interpret an $var as TEXT"

                 Thanks for the reply - I have many other scripts with $vars that don't treat the number as a text - should I use the GetAsValue on all $vars to be sure they are numbers?

                  

                 Thanks

            • 3. Re: Is this a Bug?
              raybaudi

                   It depends...

                   $var = 1 is a text but, as said, $var = GetAsNumber ( $var ) is a number.
                   The variable is also a number when it is calculated using an aritmetic operator like:

                   $var = $var + 1
                   $var = 1*1
                   $var = 1+0

                   or when it is calculated with a numeric function like:

                   $var = Max ( 1 ; 2 ; 3 )

              • 4. Re: Is this a Bug?
                BruceRobertson

                     Rich: there is no function "GetAsValue".

                     Existing functions include GetAsNumber; GetAsDate; GetAsText; etc.

                     See relevant section here:

                     https://fmhelp.filemaker.com/fmphelp_13/en/html/help_func_alpha.html#270332

                • 5. Re: Is this a Bug?
                  RichNasser

                       understood -

                       the only difference I could find in my scripts (i.e. comparing the one that treated as text vs the others that treated as number) is that with the $var that was text came directly from a user input box directly into the script.  All others were either sourced from a table (with numeric validation etc) or if it came from an input box, it was 'saved' to the field first, went thru some sort of validation scripts, and then assigned to the $var - this MAY explain the difference....

                        

                       Thanks for all your input!

                  • 6. Re: Is this a Bug?
                    RichNasser

                         @Bruce

                         yep my mistake in the GetAsNumber reply ;)

                    • 7. Re: Is this a Bug?
                      philmodjunk

                           It has not been my experience that FileMaker always treats a $Var as text. It can depend on how the $Var is assigned a value.

                           As an example, this expression:

                           let ( [$Var1 = 2 ; $Var2 = "2" ] ;
                                  list (10 > $Var1 ; 10 > $Var2 )
                                 )

                           Yields two return separated values of 1, 0. Which means that 10 > $Var1 evaluates as true, but 10 > $Var2 evaluates as false.

                           A script using set variable to set $var1 to 2 and $var2 to "2" yields identical results.

                           Thus, you may want to take a look at how your variable is assigned a value.

                      • 8. Re: Is this a Bug?
                        raybaudi

                        "It has not been my experience that FileMaker always treats a $Var as text"

                             Your example confirms what I said

                        • 9. Re: Is this a Bug?
                          philmodjunk

                               On the contrary. In my examples, $Var1 is treated as a number and $Var2 is treated as text. Thus a $Var is not always treated as text.

                          • 10. Re: Is this a Bug?
                            raybaudi

                                 Phil

                                 I do not know why your example works... it never worked for me before today.

                                 From Filemaker Help:

                                 Notes
                                 • Variables are only supported in script steps that use stored file paths.
                                 • Variables are not supported in file paths that are stored in container fields.
                                 • Variables are not supported in FileMaker data source references.
                                 • The data type of a variable is determined dynamically based on the assigned data. The default data type is text.

                            • 11. Re: Is this a Bug?
                              philmodjunk

                                   But look at the sentence in red--which explains why my example works:

                                   

                              The data type of a variable is determined dynamically based on the assigned data. The default data type is text.

                                   When I use 2 as my value to assign to a variable, it's a number data type. When I use "2" it's text. This is exactly in agreement with the documentation that you quote.

                                   This is yet another example of how FileMaker handles data typing in a dangerously "loose" fashion. It isn't always obvious what data type will be assigned when the variable was created with a set field script step or Let function call.

                                   I would much prefer variables that have to have a data type explicitly specified before they can have a value assigned.

                              • 12. Re: Is this a Bug?
                                raybaudi

                                     However, I am convinced that there must have been some change in how it behaves the $var in the latest versions.

                                     I have to go and try your calculation on 9.

                                • 13. Re: Is this a Bug?
                                  philmodjunk

                                       My use of variables goes as far back as v10 so I don't know what 9 was able to do. (I skipped from 5.5 to 10 a few years ago) wink