× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I had to write this myself about a month ago.  Here's what I came up with.
This is Visual Age RPG, but should compile on the AS/400 with few
modifications.

      *** Check Digit Variables ***
     D                 DS
     D CheckChar               1      1A
     D CheckNum                1      1S 0

     D                 DS
     D CheckDigit              1      1S 0
     D CheckDigitAlp           1      1A

     D Weight          S              1S 0
     D CheckTotal      S              3S 0

      *** BARCODE File ***
     D Barcode         S             11A
     D @Barcode        S               *   Inz(%Addr(Barcode))

      *****************************
      *** Calculate Check Digit ***
      *****************************

     C     CalcCheckDig  BegSR

     C                   Eval      Weight = 3
     C                   Eval      CheckTotal = 0

     C     1             Do        11            X
     C                   Eval      CheckChar = %SubSt(Barcode: X: 1)
     C                   Eval      CheckTotal = CheckTotal + CheckNum *
Weight
     C                   If        ( Weight = 1 )
     C                   Eval      Weight = 3
     C                   Else
     C                   Eval      Weight = 1
     C                   EndIf
     C                   EndDo

     C     CheckTotal    DIV       10            CheckTotal
     C                   MVR                     CheckDigit

     C                   If        CheckDigit <> 0
     C                   Eval      CheckDigit = 10 - CheckDigit
     C                   EndIf

     C                   EndSR

Regards,

Jim Langston


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.