Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check digit 11 Algorithm (vfp function)
Message
From
30/09/2002 06:10:27
 
 
To
30/09/2002 05:56:20
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00705844
Message ID:
00705846
Views:
9
Hello Petros,

i not exactly sure what algorithm you mean, but it could be the following,
the locals are named in german but i think you'll get the concept



FUNCTION modulo11
LPARAMETERS pcZiffer
IF TYPE('pcZiffer') = 'N'
pcZiffer = STR(pcZiffer,11)
ENDIF

LOCAL xj, lnGewichtung, lnNumber, lnZwischenProdukt, lnEndProdukt, lnRest, ;
lnPruefZiffer

m.lnGewichtung = 7
m.lnNumber = 0
m.lnZwischenProdukt = 0
m.lnEndProdukt = 0

FOR m.xj = 1 TO 11
m.lnGewichtung = m.lnGewichtung - 1
IF m.lnGewichtung = 1
m.lnGewichtung = 7
ENDIF
m.lnNumber = VAL(SUBSTR(pcZiffer,m.xj,1))
m.lnZwischenProdukt = m.lnNumber * m.lnGewichtung
m.lnEndProdukt = m.lnEndProdukt + m.lnZwischenProdukt
ENDFOR

m.lnRest = MOD(m.lnEndProdukt,11)

m.lnPruefZiffer = 11 - m.lnRest

IF m.lnPruefZiffer = 10 OR m.lnPruefZiffer = 11
m.lnPruefZiffer = 0
ENDIF

m.lnPruefZiffer = ALLTRIM(STR(m.lnPruefZiffer))
RETURN m.lnPruefZiffer
ENDFUNC


Regards

Christian
Previous
Reply
Map
View

Click here to load this message in the networking platform