Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate check digit
Message
De
28/01/2002 19:25:12
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00611887
Message ID:
00611966
Vues:
26
>hi all:
>
>Does anyone know of a program written in forxpro that calculates a check digit?

This is the mod11.prg which we were using for the last ten years (I've only beautified it and translated the variable names), but it calculates only the modulo 11 check digit. It takes the number and desired length as parameters:
* mod11.prg
para tcField, tnLength
local iCnt, cValue, nLength, nCsum, cRetVal
if type('tcField')='N'
	cValue=tran(tcField, "@L "+replicate("9",tnLength))
else
	cValue=padl(alltrim(tcField),"0", tnLength)
endif
nCsum=0
for iCnt=1 to nLength
	nCsum=nCsum + (asc(subs(cValue,iCnt))-48)*(nLength+2-iCnt)
endf
nCsum=11-mod(nCsum,11)
if nCsum=11
	cRetVal=repl("0",nLength+1)
else
	nCsum=iif(nCsum>9,nCsum-10,nCsum)
	cRetVal=cValue+str(nCsum,1)
endif
retu cRetVal

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform