3 Replies Latest reply on Nov 25, 2016 7:40 AM by philmodjunk

    isEmpty (field) & GetAsNumber (field)


      Hello everyone,

      I have two quick curious questions.


      1) The use of isEmpty (FIELD)

      Some people use the expression like: if (FIELD_A = “”; …..

      others use the expression: If (isEmpty (FIELD:A); …..

      is there any specific advantage of using one or the other ?


      2) GetAsNumber (field)

      When I updated older solutions to FMP14 I found in formulas that the expression was changed

      It was like: If (FIELD_B ≠ FIELD_C; …..

      Now it looks like: If (GetAsNumber (FIELD_B) ≠ GetAsNumber (FIELD_C); …..

      Is there any specific reason the “GetAsNumber” was automatically added ?


      Thank You,


        • 1. Re: isEmpty (field) & GetAsNumber (field)

          1) If FIELD is text there may be no difference. Otherwise, IsEmpty() check the field content direct, ="" may convert the field value to text before compare to empty string.


          2) If both fields are same type, it is not necessary. But if FIELD_C (or right hand calculation result) is text, FIELD_B is converted text like as GetAsText ( FIELD_B) = FIELD_C, and GetAsText() function get text value from field instead of converting number vlaue to text.

          Old version doesn't work as this, always refer number value from number field.

          1 of 1 people found this helpful
          • 2. Re: isEmpty (field) & GetAsNumber (field)
            David Moyer


            I wish it was a lot more strict; but from my testing It seems that FM will work any way you might hope it would regarding these functions ...

            IsEmpty(TextField) same as TextField = ""

            IsEmpty(NumberField) same as NumberField = ""

            IsEmpty(DateField) same as DateField = ""

            IsEmpty(ContainerField) same as ContainerField = ""

            Text1 = "5"; Text2 = "6", Text1 + Text2 same as GetAsNumber(Text1) + GetAsNumber(Text2)

            GetAsNumber("a1b2c3") + 5 same as "a1b2c3" + 5 same as 123 + 5

            It all comes down to preference - ostensibly.  Half-a-dozen of one, six of the other.  I prefer explicit over implicit coding.

            1 of 1 people found this helpful
            • 3. Re: isEmpty (field) & GetAsNumber (field)

              With regards to 2) I saw the same thing when I converted a Version 4 DB to 10. It was very irritating and I removed the added GetAsNumber function call each time I encountered it while updating a given calculation. In all the cases where I removed it, it had no effect on the calculated results except once. But there was that one time. It's too long ago to remember the details, but I seem to recall that it wasn't a simple "data type" issue either.


              My best guess is that the file conversion code used to convert the file does this as a precaution as there seemed to be some calculation engine updates and as a result, a small number of calculations might evaluate differently. Instead of trying to find and insert this function into just those expressions, the software inserted it everywhere.

              1 of 1 people found this helpful