USE vipkup
GOTO top
DO WHILE !EOF()
a1=SUBSTR(vipkup.barkod,1,12)
lnsum=0
lnj=0
mkontr=0
tctext=a1
    FOR lnI = LEN(tctext) TO 1 STEP -1
      lnJ = lnJ + 1
      lnSum = lnSum + (VAL(SUBSTR(tcText, lnI, 1)) * IIF(MOD(lnJ, 2) = 0, 1, 3))
    ENDFOR
    mkontr=TRANSFORM(MOD(10 - MOD(lnSum, 10), 10))
	mmsifra=ALLTRIM(a1)+ALLTRIM(mkontr)
replace vipkup.bar1 WITH mmsifra
SKIP
ENDDO
