1 2 Previous Next 20 Replies Latest reply on Oct 3, 2012 1:32 PM by comment

    What data type are you?

    vince.menanno

      I think it would be helpful to have a native built in function to determine what a value you are working with is. Or at least what FileMaker thinks it is.

       

      In the FileMaker DNA values are often considered at text unless you specify otherwise.

       

      In some recent work we were using ExecuteSQL to get the sum of some number field. And a fairly complicated multi predicate set of search options. Scratching our heads for some time as to why we were not getting the anwers we were expecting. Only to find that it was returning .5 and we had a Case statement say somethign like Case ( result > 0; result; 0 ). We were looking to get .5 but .5 if FileMaker is treating that as TEXT in this opreration it woudl return 0 becase ".5" as TEXT is not greater than "0".

       

      So if there was some way that we could doulbe check what FileMaker is interpreting the value as that would be super.

       

      Maybe something like DataType ( value )

       

      Thanks

        • 1. Re: What data type are you?
          wsvp

          Hi Vince

           

          I always use the GetAsNumber (), GetAsDate (), Etc...  Assuming you are calculating in the FileMaker domain.  Unless I am missing something in your post.

          • 2. Re: What data type are you?
            vince.menanno

            I am thinking along the lines of IsValid. Sometimes FileMaker might have a string that looks like a timestamp and you think its a timestamp but FileMaker really thinks its working with TEXT. So I think it would be useful to have a function where you can ask FileMaker what is the data type of the item in question.

             

            Along the lines of IsValid but IsValid assumes you already know what the datatype you are working with and FileMaker will check to make sure its valid.

            • 3. Re: What data type are you?
              comment

              vince.menanno wrote:

               

              In the FileMaker DNA values are often considered at text unless you specify otherwise.

               

              I don't think that's an accurate statement.

              • 4. Re: What data type are you?
                wsvp

                Because FileMaker is looking for the developer to make the decision as to the type of value,  I think the GetAsNumber (), GetAsDate (), Etc. are very intuitive.  In a complex string of text the "type of value" could be open for interpretation.  Unless FileMaker implements the "ExtraSensoryPerception ()" function (and believe me... there are some Clients who expect this)... I could see no way to accomplish what you are looking for without loosing the power we have.

                • 5. Re: What data type are you?
                  vince.menanno

                  Why don't you think its accurate.

                   

                  In the early days of the plug-in API for example everything was TEXT.

                   

                  Even now if you think you are workin with numbers - unless you specify to FileMaker that the value you are giving it is indeed a number I think sometimes you could end up being surprised. I am sure there are some examples about this ... just don't have one right now.

                  • 6. Re: What data type are you?
                    eshoshin

                    "ExtraSensoryPerception ()" function  <-----  This actually made me almost spit out my coffee... hilarious!

                    • 7. Re: What data type are you?
                      gdurniak

                      This just happened to me as well, so I am now more careful to "get as number"

                       

                      I suspect your "result" was $result, a variable, which can be anything

                       

                      In the true "FileMaker DNA", a more accurate feature request might just be smarter functions.

                       

                      Since you had  Case > 0 ( a number ) , and not  Case > "0" ( text ),  Filemaker could know what you mean, and type cast accordingly

                      ( or warn of a possible mismatch )

                       

                      greg

                       

                      > In the FileMaker DNA values are often considered at text unless you specify otherwise

                      • 8. Re: What data type are you?
                        vince.menanno

                        Thanks Greg

                        • 9. Re: What data type are you?
                          comment

                          vince.menanno wrote:

                           

                          Even now if you think you are workin with numbers - unless you specify to FileMaker that the value you are giving it is indeed a number I think sometimes you could end up being surprised. I am sure there are some examples about this ... just don't have one right now.

                           

                          Well, I am willing to make the following deal; you show me where you end up being surprised, and I'll show you where you made a mistake.

                          • 10. Re: What data type are you?
                            beverly

                            And often I use TEXT that is a "formatted" number or date. So is it text or ??

                              IF I need to calculate and use the symbol "+", I should hope all values are cast as numbers (even dates are number of days...). If I use "&"  to concatenate, I should hope that all values are cast as text.

                              But I know because I am crossing the line with the number-formatted-is-text, I'm content to do my own casting when needed.

                             

                            -- sent from my iPhone4 --

                            Beverly Voth

                            --

                            • 11. Re: What data type are you?
                              vince.menanno

                              Beverly,

                               

                              Adn Brian commented on this at work - it mgith be enough to say that I am expecting it back as a particular type. For example you can fabriat

                               

                              Also as gdurniak said mabye the solution to my problem was to be more careful when I was using my Case statement at the time I am comparing them to instead request it as number.

                               

                              Case > 0 ( a number ) , and not  Case > "0" ( text ) - thanks gdurniak

                               

                              Ok as my neighbor would say when he had enough of my playing my tounge drum for hours - Enough Already All good.

                              • 12. Re: What data type are you?
                                brianbee

                                Hi all,

                                 

                                We've been discussing this in-house today, prompted by Vince's and Greg's SQL results. FWIW, we're reviewing the idea of a lightweight, Ruby-inspired custom function to help in these cases. Here it is:

                                .  .  .  .  .  .  .  .  .  .  .  .  .

                                 

                                respondsTo ( value ; type )

                                 

                                Case (

                                 

                                IsEmpty ( value ) ;

                                "<value is empty>" ;

                                 

                                type = "number" ;

                                GetAsNumber ( value ) = value ;

                                 

                                type = "date" ;

                                GetAsDate ( value ) = value ;

                                 

                                type = "time" ;

                                GetAsTime ( value ) = value ;

                                 

                                type = "timestamp" ;

                                GetAsTimestamp ( value ) = value ;

                                 

                                type = "text" ;

                                GetAsText ( value ) = value ;

                                 

                                "<type is invalid>"

                                )

                                /*

                                a simple test (loosely inspired by ruby) to determine if a value can be treated as a specified data type.

                                note that values can often respond to more than one type (eg, a timestamp can also be treated as time, date, or text).

                                 

                                brian schick, beezwax datatools, 2012.oct.02. v 0.1.

                                */

                                .  .  .  .  .  .  .  .  .  .  .  .  .

                                 

                                FWIW, our intent is to ask a given chunk of data whether it can accurately be treated as (or in Ruby parlance, if it responds to) the data type we're interested in at the point we want to use it. Because pieces of data can often be accurately treated as multiple data types, and because the concept of type can subtly shift in FileMakler depending on where we are at a given point, we're more interested in whether data can be treated as our desired type, rather than whether it *is* a certain type.

                                 

                                This also allows a semantically clean form if inquiry, like so:

                                 

                                if ( respondsTo ( $_myVar ; "number" ) …

                                 

                                Best,

                                Brian

                                • 13. Re: What data type are you?
                                  jrenfrew

                                  Thats an interesting approach Brian.

                                  • 14. Re: What data type are you?
                                    comment

                                    Brian Schick wrote:

                                     

                                    we're more interested in whether data can be treated as our desired type, rather than whether it *is* a certain type.

                                     

                                    I am not sure that's what your function tests for. For example =

                                     

                                    Let ( value = "0.1" ; GetAsNumber ( value ) = value )

                                     

                                    returns False. Does that mean that the value cannot be treated as a number?

                                    1 2 Previous Next