Brilliant Christof
Many thanks
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Wollenhaupt, Christof Sent: 16 April 2018 15:36 To: profoxtech@leafe.com Subject: Re: Modulo 97 of a very large number
I need to calculate N % 97 aka Mod(N,97) for very large numbers containing 28 digits. Obviously VFP can't handle numbers that large but maybe somebody can suggest some kind of piece-wise method that would enable me to calculate what I need?
Sounds like an IBAN checksum calculation.
Procedure IBAN (tcCountry, tcBBAN) Local lnChk, lcIBAN lnChk = 98 - This.CheckSum (m.tcCountry+"00"+m.tcBBAN) lcIBAN = m.tcCountry + Padl( Alltrim (Str(m.lnChk)), 2, "0") + m.tcBBAN Return m.lcIBAN
Procedure Checksum (tcIBAN)
Local lcBBAN, lcLK1, lcLK2, lcDigits lcBBAN = Substr (m.tcIBAN, 5, 18) lcLK1 = TRANSFORM (ASC (Left (m.tcIBAN,1))-55,"@L 99") lcLK2 = TRANSFORM (ASC (SUBSTR (m.tcIBAN,2,1))-55,"@L 99") lcDigits = m.lcBBAN + m.lcLK1 + m.lcLK2 + Substr(m.tcIBAN,3,2)
Local lnMod, lnPos, lnDigit lnMod = 0 For lnPos = 1 to Len(m.lcDigits) lnDigit = Val (Substr (m.lcDigits, m.lnPos, 1)) lnMod = ((m.lnMod * 10) + m.lnDigit) % 97 EndFor
Return m.lnMod
If you by chance need to generate German SEPA XML files, we have a VFP solution for that. It should be adoptable for other countries with minor changes.
-- Christof