Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calcualation on large number
Message
 
To
20/09/2013 09:52:40
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01583702
Message ID:
01583724
Views:
69
>>>Hi.
>>>I need to be able to do Mod(MyNum,97)
>>>But Mynum, whcih results from a string of digits, could be more than 30 characters
>>>(This is part of a Banking Application to generate an IBAN check Digit )
>>>
>>>Can Foxpro do this correctly
>>>I've done a few tests with a long number and it does not seem to work
>>>( I know one option is to take up to 7 characters at a time and do it this way but wonder if this can be avoided)
>>>
>>>Tia
>>>Gerard
>>
>>IBAN control?
>>Here:
>>
>>? CheckIBAN("BG94EASYPAY19999999998") && .t.
>>? CheckIBAN("BG94EASYPAY19999999997") && .f.
>>
>>FUNCTION CheckIBAN(lcIBAN, lbNotToAsk, lbOtherFonts)
>>LOCAL lcString, lnFor, lcOneSymb, lcOstatak, lnMod97
>>LOCAL lbReturnValue
>>m.lcIBAN   = ALLTRIM(m.lcIBAN)                   && Remove all intervals
>>IF VARTYPE(m.lcIBAN) == [C] AND BETWEEN(LEN(m.lcIBAN), 15, 31) && all IBANs should be 15->31 chars length
>>   m.lcIBAN   = SUBSTR(m.lcIBAN,5)+LEFT(m.lcIBAN,4) && Move first 4 chars at the end
>>   m.lcString = []
>>
>>   FOR m.lnFor = 1 TO LEN(m.lcIBAN)        && All letters to numbers [ A - 10, B-11 ...  Z-35]
>>       m.lcOneSymb = SUBSTR(m.lcIBAN,m.lnFor,1)
>>       IF ISDIGIT(m.lcOneSymb)
>>          m.lcString = m.lcString + m.lcOneSymb
>>       ELSE
>>          m.lcString = m.lcString + TRANSFORM((ASC(m.lcOneSymb)-55))
>>       ENDIF
>>   NEXT
>>   m.lcOstatak = []
>>   DO WHILE NOT EMPTY(m.lcString)
>>      m.lcOneSymb = VAL(m.lcOstatak + LEFT(m.lcString,1))
>>      m.lnFor     = INT(m.lcOneSymb/97)
>>      m.lcOstatak = TRANSFORM(INT(m.lcOneSymb - m.lnFor*97))
>>      m.lcString  = SUBSTR(m.lcString,2)
>>   ENDDO
>>   m.lnMod97 = VAL(m.lcOstatak)
>>   m.lbReturnValue = (m.lnMod97 == 1)                                && Everything is OK if the remainder is 1
>>ENDIF
>>
>>RETURN  m.lbReturnValue
>>
>
>Boris,
>
>Hmmm, please change your first line into
>
>
>? CheckIBAN("BG94EASYPAY19999999999") && .t.
>
>
>Regards,
>
>Koen


:-)
I can't anymore, wht I have answer I can't change the post (or at least that was in the previous version of UT).
But you are right this is fully fictional IBAN and it should end with 9 not with 8.
Sorry.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform