/* REXX */
"EXECIO * DISKR INFILE (STEM RECORDS. FINIS"
SUM = 0
DO I = 1 TO RECORDS.0
IF SUBSTR(WORD(RECORDS.I,1),1,5) = 'xxxxx' THEN ITERATE
IF SUBSTR(WORD(RECORDS.I,1),1,5) = 'xxxx' THEN ITERATE
IF SUBSTR(WORD(RECORDS.I,1),1,6) = 'xxxx' THEN ITERATE
NUMBER.I = SUBSTR(WORD(RECORDS.I,1),6,12)
END
DO J=1 TO RECORDS.0
IF SUBSTR(WORD(NUMBER.J,1),1,6) = 'xxxx' THEN ITERATE
R=CHECKSUM(NUMBER.J)
IF R==0 THEN VALID.J = NUMBER.J
ELSE INVALID.J = NUMBER.J
END
/* IF R==0 THEN SAY NUMBER.J " VALID CARD!"
ELSE SAY NUMBER.J " INVALID CARD!" */
"EXECIO * DISKW OUTFILE1 (STEM VALID. FINIS"
"EXECIO * DISKW OUTFILE2 (STEM INVALID. FINIS"
/* END */
EXIT
CHECKSUM: PROCEDURE; PARSE ARG T
IF LENGTH(T)//2 THEN T='0'T
T=REVERSE(T)
S=0
DO J=1 TO LENGTH(T)-1 BY 2
Q=2*SUBSTR(T,J+1,1)
IF Q>9 THEN Q=LEFT(Q,1)+RIGHT(Q,1)
S=S+SUBSTR(T,J,1)+Q
END
RETURN S//10\==0
"EXECIO * DISKR INFILE (STEM RECORDS. FINIS"
SUM = 0
DO I = 1 TO RECORDS.0
IF SUBSTR(WORD(RECORDS.I,1),1,5) = 'xxxxx' THEN ITERATE
IF SUBSTR(WORD(RECORDS.I,1),1,5) = 'xxxx' THEN ITERATE
IF SUBSTR(WORD(RECORDS.I,1),1,6) = 'xxxx' THEN ITERATE
NUMBER.I = SUBSTR(WORD(RECORDS.I,1),6,12)
END
DO J=1 TO RECORDS.0
IF SUBSTR(WORD(NUMBER.J,1),1,6) = 'xxxx' THEN ITERATE
R=CHECKSUM(NUMBER.J)
IF R==0 THEN VALID.J = NUMBER.J
ELSE INVALID.J = NUMBER.J
END
/* IF R==0 THEN SAY NUMBER.J " VALID CARD!"
ELSE SAY NUMBER.J " INVALID CARD!" */
"EXECIO * DISKW OUTFILE1 (STEM VALID. FINIS"
"EXECIO * DISKW OUTFILE2 (STEM INVALID. FINIS"
/* END */
EXIT
CHECKSUM: PROCEDURE; PARSE ARG T
IF LENGTH(T)//2 THEN T='0'T
T=REVERSE(T)
S=0
DO J=1 TO LENGTH(T)-1 BY 2
Q=2*SUBSTR(T,J+1,1)
IF Q>9 THEN Q=LEFT(Q,1)+RIGHT(Q,1)
S=S+SUBSTR(T,J,1)+Q
END
RETURN S//10\==0