Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate check digit
Message
From
28/01/2002 19:25:12
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00611887
Message ID:
00611966
Views:
25
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform