Breezer Posted May 19, 2006 Posted May 19, 2006 Has anyone implemented the MOD10A into FileMaker? If yes, how did you go about it to achieve the same results that this code would generate?
SteveB Posted May 19, 2006 Posted May 19, 2006 Ray Cologon of Nightwing implemented Mod 10 in a previous version (6 I think). I created custom functions based on his work. Go to Link, or if you want the Custom Functions, let me know. Steve
Søren Dyhr Posted May 19, 2006 Posted May 19, 2006 Not that I know the difference between 10 and 10a, but I gave it a stab, based on this: http://www.ee.unb.ca/tervo/ee4253/luhn.html My suggestion goes like this: 1) a repeating calc'field with 16 reps. containing: Substitute ( Abs(Middle ( Extend ( entry ) ; Get ( CalculationRepetitionNumber ) ; 1 )) * (Mod(Get ( CalculationRepetitionNumber );2)+1) ;["10";"1"];[ "12" ; "3"];["14";"5"];["16";"7"];["18";"9"] ) ...which resulting type is number let's call it "split" 2) A checkfield that ought to reach 0 if the card validation turn out correct: Mod(Sum ( split );10) Next step would be to rewrite it to a CF. --sd
Breezer Posted May 19, 2006 Author Posted May 19, 2006 Thank you steve and Soren for the superfast response. I was reading up on it, and i found that if the (odd)number*2 is greater than 9, one can simply subtract 9 from it which is easier to implement than getting the number then adding the digits. I will try your suggestions then follow-up with you.
Fitch Posted May 19, 2006 Posted May 19, 2006 Not the most elegant calc in the world, but it seems to do the job: // Returns 1 if checksum matches Let ( [ it = gCard ID ; len = Length ( it ) ; mid1 = GetAsNumber( Middle ( it ; len-1 ; 1 ) * 2 ); mid2 = GetAsNumber( Middle ( it ; len-2 ; 1 ) ) ; mid3 = GetAsNumber( Middle ( it ; len-3 ; 1 ) * 2 ) ; mid4 = GetAsNumber( Middle ( it ; len-4 ; 1 ) ) ; mid5 = GetAsNumber( Middle ( it ; len-5 ; 1 ) * 2 ) ; mid6 = GetAsNumber( Middle ( it ; len-6 ; 1 ) ) ; mid7 = GetAsNumber( Middle ( it ; len-7 ; 1 ) * 2 ) ; mid8 = GetAsNumber( Middle ( it ; len-8 ; 1 ) ) ; mid9 = GetAsNumber( Middle ( it ; len-9 ; 1 ) * 2 ) ; mid10 = GetAsNumber( Middle ( it ; len-10 ; 1 ) ) ; mid11 = GetAsNumber( Middle ( it ; len-11 ; 1 ) * 2 ) ; mid12 = GetAsNumber( Middle ( it ; len-12 ; 1 ) ) ; mid13 = GetAsNumber( Middle ( it ; len-13 ; 1 ) * 2 ) ; mid14 = GetAsNumber( Middle ( it ; len-14 ; 1 ) ) ; mid15 = GetAsNumber( Middle ( it ; len-15 ; 1 ) * 2) ] ; Right ( it ; 1 ) = Mod ( 10 - Mod ( Case( len < 2 ; 0 ; mid1 < 10 ; mid1 ; mid1 - 9 ) + Case( len < 3 ; 0 ; mid2 < 10 ; mid2 ; mid2 - 9 ) + Case( len < 4 ; 0 ; mid3 < 10 ; mid3 ; mid3 - 9 ) + Case( len < 5 ; 0 ; mid4 < 10 ; mid4 ; mid4 - 9 ) + Case( len < 6 ; 0 ; mid5 < 10 ; mid5 ; mid5 - 9 ) + Case( len < 7 ; 0 ; mid6 < 10 ; mid6 ; mid6 - 9 ) + Case( len < 8 ; 0 ; mid7 < 10 ; mid7 ; mid7 - 9 ) + Case( len < 9 ; 0 ; mid8 < 10 ; mid8 ; mid8 - 9 ) + Case( len < 10 ; 0 ; mid9 < 10 ; mid9 ; mid9 - 9 ) + Case( len < 11 ; 0 ; mid10 < 10 ; mid10 ; mid10 - 9 ) + Case( len < 12 ; 0 ; mid11 < 10 ; mid11 ; mid11 - 9 ) + Case( len < 13 ; 0 ; mid12 < 10 ; mid12 ; mid12 - 9 ) + Case( len < 14 ; 0 ; mid13 < 10 ; mid13 ; mid13 - 9 ) + Case( len < 15 ; 0 ; mid14 < 10 ; mid14 ; mid14 - 9 ) + Case( len < 16 ; 0 ; mid15 < 10 ; mid15 ; mid15 - 9 ) ; 10 ) ; 10 ) // end mod ) // end let
comment Posted May 19, 2006 Posted May 19, 2006 I believe you missed this part: It is important when applying this method to numbers of different lengths that the rightmost digit (the check digit) is always multiplied by 1 and not by 2. So it breaks when the length of entry is odd. I would do it this way: Let ( [ num = GetAsNumber ( Extend ( Input ) ) ; i = Get ( CalculationRepetitionNumber ) ; len = Length ( num ) ; pos = len - i + 1 ; digit = Middle ( num ; pos ; 1 ) ] ; Case ( i ≤ len ; Case ( Mod ( i ; 2 ) ; digit ; Div ( 2 * digit ; 10 ) + Mod ( 2 * digit ; 10 ) ) ) )
Søren Dyhr Posted May 20, 2006 Posted May 20, 2006 I believe you missed this part I did - by just investigating the algoritm in the referenced page, without further reading, from where it seemed easy piecy! Thanks for taking you time (as usual) to pinpoint flaws in my reasoning, I tends to believe it gets me somewhere? So please continue to do so - no need to excuse when you dissagre. Both discourse and reasoning needs it - eventhough meritocracy might be somewhat utopia? If we ever should have a "qoute of the year" award should it in my opinion go to this: However, I have found that indulging in some impractical abstract theory has always changed the way I work in a markedly beneficial way (even if the result is far from the original hypothesis) once I get back to the nuts and bolts of specific projects. --sd
Breezer Posted May 22, 2006 Author Posted May 22, 2006 Based on all your inputs, I'm happy to state that all your methods are much better than the way i was approaching it. Thanks to all.
Recommended Posts
This topic is 6759 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now