Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calcualation on large number
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01583702
Message ID:
01583704
Vues:
87
>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
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform