6 Replies Latest reply on Mar 3, 2017 5:39 AM by flusheddata

    Buggy Middle?

    flusheddata

      Hi,

      I've found out that the following functions behave oddly:

      Middle ( "Test" ; 0 ; 1 ) = "T" Unexpected result. Should not it be Empty?

      Middle ( "Test" ; "" ; 1 ) = "T" Should not it be Empty?

      Middle ( "Test" ; 5 ; 1 ) = "" Expected result

       

      The same happens with MiddleWords () and MiddleValues ().

       

      Why should I use Middle with 0 or Empty? Because I want to set the Start argument programmatically and sometimes it has to be zero.

       

      Best regards,

      Miguel

        • 1. Re: Buggy Middle?
          beverly

          Except the "starting point" is one for these functions.

          Start with the first character (inclusive) and return one character is:

          Middle ( text ; 1 ; 1 )

           

          While some programming indexes start with 0, these start with 1.

           

          Sent from miPhone

          1 of 2 people found this helpful
          • 2. Re: Buggy Middle?
            flusheddata

            Thank you Beverly for your quick reply.

            I know FileMaker uses one based indexes. I may have explained wrongly (blame it to my poor English, I apologise).

            It seems that FileMaker "forces" the starting point to be 1 dispite of it beging 0 (zero) or "" (empty).

            Because Middle ( "Test" ; 5 ; 1 ) gives nothing as there is no position 5 in the word "Test" I thought It would do so with Middle ( "Test" ; 0 ; 1 ).

            I kind of find it pointless the following to be equivalent:

            Middle ( "Test" ; 1 ; 1 ) // -> T

            Middle ( "Test" ; 0 ; 1 ) // -> T

            Middle ( "Test ; "" ; 1 ) // -> T

            That's it.

            Best regards,

            Miguel

            • 3. Re: Buggy Middle?
              user19752

              Maybe FMI thought "start should be 1 or greater, so otherwise use 1". There is many things not described in help, like if it is not integer, use Int(start).

               

              The behavior is not changed from old versions, so reporting it as bug wouldn't worth. You can workaround it with making custom function etc.

              1 of 1 people found this helpful
              • 4. Re: Buggy Middle?
                flusheddata

                Thank you for your reply.

                I wish they had thought 'if start is greater than length then set it to length'. But not, it shows empty. That is why I 'still' consider it a bug. I do not believe  a bug becomes a feature because it is never fixed. Though sometimes you cannot fix it for compatibility reasons.

                I have a custom function which combines the Right and Left functions to get a true middle function. Workarounds work of course.

                Kind regards,

                Miguel

                • 5. Re: Buggy Middle?
                  beverly

                  I'm not sure why this reply did not make it to the forum (2017 2nd Mar, 07:40):

                   

                  ok, so you mean that

                  Middle ( "Test" ; 0 ; 1 ) = Middle ( "Test" ; 1 ;1 )

                  = Middle ( "Test" ; "" ; 1 )

                  ?

                   

                  and

                  Middle ( "Test" ; 5 ; 1 ) = ""

                  ?

                   

                  OK, I do understand now what you are saying.

                  This is also true:

                  Middle ( "Test" ; -1 ; 1 ) = "T"

                   

                  The 'start' is 1 or any value up to & including the Length() of the text being tested

                   

                  I don't think it's buggy, but you are entitled to your opinion. I also test for "" and the Length() of things as needed before using other functions such as Middle().

                   

                  beverly

                  1 of 1 people found this helpful
                  • 6. Re: Buggy Middle?
                    flusheddata

                    Thank you for your reply Beverly.

                    I am glad you got the point.

                    They've chosen to use 1 as the start point regardless of it being -1, 0 or "". But they have chosen it to be empty if it is greater than the length. That's why I consider it a bug, because of its lack of consistency.

                     

                    On the other hand,  should you use a variable's value or a field's value as the start point you'd run into troubles if those values "needed" to be zero. It happened to me while making cryptography functions.

                     

                    Anyway, as I estated earlier, there are workarounds such as custom functions.

                     

                    Best regards,

                    Miguel