April 19, 200421 yr I was reading this post about credit card number formatting, and went to take a look at Brian Dunning's "Credit Card Validator" file, which works only with FM5 and FM6. I converted Brian's file using DEV7, and the behavior of the program changed. Card numbers that were valid prior to conversion were now invalid. I poked around the calculations, looking for oddities in the conversion, and found what might be a bug in FM7. If you look at the calculation "HalfDoubledCC" in Brian's file in FM6 and compare the calculation result in FM7, the results are very different. Here's why: In FM6 and FM7, if you enter a 5-digit numeric value into a text field ("field"), and then create a calculation as follows: Middle( field, 6, 1) the result is empty, because there is no 6th position in the string. However, now create a calculation similar to Brian's calc (noted above), using a multiplier: 2 * Middle( field, 6, 1) or, in FM7: 2 * Middle( field; 6; 1) FM6 returns an empty result. FM7, however, produces a result equal to the string multiplied by 2. So, if the value of the string is "12345", FM6 returns nothing, but FM7 returns 24690. I've attached two small files: the first file was created in FM6 and the second is the same file converted to FM7. Take a look at the calcs and results. I'd appreciate your input about whether this is a bug or a feature. Thanks a lot. FileMaker Version: Dev 7 Platform: Mac OS X Panther Wierd_Calc.zip
April 20, 200421 yr IMHO it's a bug. I changed the calc to this: 2 * GetAsNumber( If( IsEmpty(Middle(SomeText; 6; 1)); "0"; Middle(SomeText; 6; 1) ) ) and it properly returned 0. FYI: it returned the wrong result with: 2 * GetAsNumber(Middle(SomeText; 6; 1)) So, Middle(SomeText; 6; 1) can be properly evaluated as empty. So why didn't 2 * properly evaluate Middle(SomeText; 6; 1)? My suspicion is the calculation parser has improperly handled Middle returning an empty string when the operand is numeric.
April 20, 200421 yr I concur; i believe it to be a bug as well. However if it's not a bug, it's a purdy unusual "feature". FileMaker Version: Dev 7 Platform: Windows XP
Create an account or sign in to comment