* 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