For a bar code with n digits (n is always an odd number)
--------------------------------------------------------------------------------
* Modulo 10 self check digit calculation (UPC)
* & Interlaced 2 of 5
* Written by: Steven Easton 11/04/91
*
* The zebra printer calculated modulo-10 check character by:
* Check digit calculation for the number 01234567890
* 1. Starting at the left, sum the characters in the
* odd positions (first from the left, third from
* the left, and so on), Starting with the number
* system character. (for the upc-a bar
* code example, 0 + 2 + 4 + 6 + 8 + 0 = 20.)
* 2. Multiply the sum obtained in step 1 by 3.
* (the product of the example is 60).
* 3. Starting at the left, sum the characters in the
* even positions. (for example, 1 + 3 + 5
* + 7 + 9 = 25.)
* 4. Add the product of step 2 to the sum of step
* 3. ( for the example, the sum is 85.)
* 5. The modulo-10 check character value is the
* smallest number that when added to the
* sum of step 4 produces a multiple of 10. (In
* the example, the check character value is 5.)
*
E MULT 19 19 1 0 UPC
E M2O5 19 19 1 0 2 OF 5
E IP# 19 1 0
E AR1 38 1 0
E AR2 19 2 0
I DS
I 1 19 IP#
I 1 190IPNO
I 1 19 IPA
I DS
I 1 38 AR1
I 1 38 AR2
C *ENTRY PLIST
C PARM CMD 3 LR, 2O5
C PARM PARM1 19 LEFT JUST
C PARM CHKDGT 10
C CMD IFEQ 'LR'
C SETON LR
C RETRN
C END
*
C MOVE PARM1 IPA
C DO 19 X 40
C CMD IFEQ '2O5'
C IP#,X MULT M2O5,X AR2,X
C ELSE
C IP#,X MULT MULT,X AR2,X
C END CMD=2O5
C END DO 19
C XFOOTAR2 SUM 60
C MOVE SUM SUM1 10
C 10 SUB SUM1 SUM
C MOVE SUM CHKDGT 10
C RETRN
**
3131313131313131313
**
2121212121212121212
-----------------------------------------------------------
PGM
DCLF SLFCHK19D
DCL &CMD *CHAR 3
SNDRCVF:
SNDRCVF () PROMPT
IF &IN03 DO
CHGVAR &CMD 'LR '
CALL SLFCHK19 (&CMD &NUMBER &CHKDGT)
RETURN
ENDDO
CALL SLFCHK19 (&CMD &NUMBER &CHKDGT)
GOTO SNDRCVF
ENDPGM
---------------------------------------------------------------