timalex Posted April 19, 2001 Posted April 19, 2001 Well, perhaps this may not tax your left half, but it does mine. I have a task to produce a check digit from a 20-digit number. I am to use Modulo 10 recursive. On paper I have created what I think is the right matrix. Rows: 009468271350 194682713509 246827135098 368271350947 482713509466 527135094685 671350946824 713509468273 835094682712 950946827131 where the first digit is my remainder, the last the check digit. I am doing it like this (in my head anyway): Number Example (CNUM): 31356756876567128765 Starting with remainder 0 (Row 1, Index '0'), I take the 1st digit of CNUM; I add 1 to this digit and index the Row to find the next remainder. I use the new remainder to find my next row. I then take the second digit of CNUM, add 1 to it and find my next remainder....and so on. My check digit should be on the 20th recursion of this. This is all very nice, but I am not really a FMPRO wiz . Questions: 1. Is this a reasonable approach? 2. If so, how can I code this in a calculation (fixed 20 digit number)? 3. Is a script better? Thanks anyone
timalex Posted April 20, 2001 Author Posted April 20, 2001 I'll take that as a don't know then shall I?
BobWeaver Posted April 20, 2001 Posted April 20, 2001 As for modulo 10 recursive, I've never heard of it before, so I'll take your word for it that your method is correct. You could do it as one calculation but it would be really ugly. If you use a script, you would have to run it everytime you change the value of CNUM. I would probably do it with several (20) calculated fields to hold intermediate results, and the final one to hold the final answer. Put the entire matrix into a global text field called "matrix" with a space between each row. That way you can retrieve a row using the MiddleWords function, and the number in the row with the Middle function. Then do an intermediate calculation for each remainder. For example, your calculation for Remainder15 would be: Remainder15 = TextToNum(Middle(MiddleWords(matrix, Remainder14, 1), TextToNum(Middle(CNUM,15,1)+1), 1)) These calculations will be virtually identical, so you can replicate all 20 of them quickly.
Recommended Posts
This topic is 8675 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