AnsweredAssumed Answered

Middle Returns Garbage Result

Question asked by on Nov 4, 2009
Latest reply on Nov 4, 2009 by TSGal


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.