3 Replies Latest reply on Nov 4, 2009 2:53 PM by TSGal

    Middle Returns Garbage Result

    david_lalonde@d-cogit.ca

      Summary

      Middle Returns Garbage Result

      Description of the issue

      FileMaker Product(s) involved:FileMaker Pro Advanced 10.0v3, no other version tested  Operating System(s) involved:Mac OS X 10.5.8, no other operating system testedDetailed description of the issue:  In producing a suite of custom functions, I stumbled across what I believe is a bug. In one of my functions, I used a statement similar to this one: Middle ($$textVariable; $$startLocation; 32) The global variable textVariable was a properly defined variable containing a 64 character string. The global variable startLocation was a properly defined variable containing a number. Although the syntax is correct, I made an error in that statement. The error? startLocation was not a position indicator for textVariable. It was a position indicator for a much larger text variable (33 344 characters long). For such a coding error, I had assumed Middle would return an empty value because startLocation was out of textVariable's bounds. Instead, it returned a string that coincidentally contained the same character range I was expecting in the first place (only 0s and 1s). I am a seasoned programmer. Because of my assumption, it took me a while to figure out my mistake. Once I figured it out, I asked myself if FileMaker Pro's behaviour in this case was indicative of a bug. Evidently, Middle does not perform any string bounds checking on variables. Imagine if FileMaker's target audience, the non programmer, were to make a similar error. This is a scenario I find very plausible. That is why I am reporting this issue. I hope this is worth something.   Expected Result: If startLocation is not within textVariable, I expect Middle to return a blank value.  Actual Result:I got a string of the requested length containing garbage characters in the expected range (0s and 1s). I suspect I got characters from another defined variable (perhaps the one with 33 344 characters).  Exact text of any error message(s) that appeared:N/A Any additional configuration information/troubleshooting that is relevant to the issue:N/A Any workarounds that you have found:Avoid making a mistake in the first place. This bug is no show-stopper. However, it sure is a time waster during debugging.

        • 1. Re: Middle Returns Garbage Result
          TSGal

          David Lalonde:

           

          Thank you for your post.

           

          Unfortunately, I am unable to duplicate the problem.  I have set up a database with some fields and trying to update fields based upon the information you gave, but I am receiving a null string when the $$startLocation value is outside the bounds of the string.

           

          Is it possible you can send a sample/clone of the file?  I have sent you a private message (top of this page - right side - X Messages) with instructions where to send the file.

           

          TSGal

          FileMaker, Inc.

          • 2. Re: Middle Returns Garbage Result
            philmodjunk
              

            Using Windows XP, FMP 10 Advanced, I also cannot replicate this issue.

             

            I ran the following script:

             

            Set Variable [$$Word; Value: "ThisStringisatLeast64CharactersLongFourScoreAndSevenYearsAgoToday" ]

            Set Variable [$$StartLocation; Value: 70 ]

            Show Custom Dialog [Quote(Middle($$Word; $$StartLocation; 32 ) )]

             

            When I run the script, I get "" as expected.

             

            Changing $$StartLocation's value to a much larger value: 870, produced identical results.

            • 3. Re: Middle Returns Garbage Result
              TSGal

              David Lalonde:

               

              I received both of your files, and I can definitely reproduce the problem.  It isn't as simple as you make it out to be in this post.  :-)

               

              I have forwarded your notes along with my findings (which coincide with yours) to our Development and Software Quality Assurance (Testing) departments for review and confirmation.  When more information becomes available, I will let you know.

               

              For others reading this thread, the problem is complex and not clear-cut, so providing specific information at this time is not possible.

               

              On a separate note, "well done" in narrowing down the offending lines in the custom function(s).

               

              TSGal

              FileMaker, Inc.