Thread: FoxPro Some General Questions/Error Detection Based on Check Digit Schemes

Error Detection Based on Check Digit Schemes
Error Detection Based on Check Digit Schemes



* 3-Weight Method
CLEAR
SET CENTURY ON
SET DATE BRITISH
SET TALK OFF
SET EXCLUSIVE OFF

m.lnStart=1134650
FOR m.lnDigit=m.lnStart TO m.lnStart+40
  m.lcDigit=ALLTRIM(STR(m.lnDigit))
  c=0
  FOR i=LEN(m.lcDigit) TO 1 STEP -1
    m.lnRem=(i%3)+1
    DO CASE
      CASE m.lnRem=1
        c=c+9*VAL(SUBSTR(m.lcDigit,i,1))
      CASE m.lnRem=2
        c=c+7*VAL(SUBSTR(m.lcDigit,i,1))
      CASE m.lnRem=3
        c=c+3*VAL(SUBSTR(m.lcDigit,i,1))
    ENDCASE
  ENDFOR
  m.lnResult=c%10
  ? m.lnResult
ENDFOR