DIGSUM = 0. I = 0. * Start: Multiply each digit of the 12 digit cgc with each digit of the * first control number (543298765432) one by one, and add the * twelve products to one sum. For Heinz: This is the scalarprod. * of 12 digit cgc and first control number. DO 12 TIMES. I = I + 1. IF I < 5. * to create the first control number. e.g. for i=1, j=5 = first digit J = 6 - I. ELSE. J = 14 - I. ENDIF. WRITE: CGC_NUMBER+0(1) TO DIGIT. DIGSUM = DIGSUM + ( DIGIT * J ). SHIFT CGC_NUMBER LEFT. ENDDO. * * End of this operation (scalarproduct). Result is digsum. * Now the result modulo 11 is calculated DIGREST = DIGSUM MOD 11. * Further manipulation to the result of the modulo operation * to prevent that first is 2-digit number (e.g. if digrest=0, first=11) IF DIGREST = 0 OR DIGREST = 1. FIRST = 0. ELSE. FIRST = 11 - DIGREST. ENDIF. * * first is the first control digit, i.e. digit 13 of the total cgc. * Now a very similar calculation for the second control digit, using * the second control number (654329876543) CGC_NUMBER = AUX. * CGC_NUMBER obtains its former value DIGSUM = 0. I = 0. DO 12 TIMES. I = I + 1. IF I < 6. J = 7 - I. ELSE. J = 15 - I. ENDIF. WRITE: CGC_NUMBER+0(1) TO DIGIT. DIGSUM = DIGSUM + ( DIGIT * J ). SHIFT CGC_NUMBER LEFT. ENDDO. * up to here the same as before. The next manipulation is an * additional operation using the first control digit 'first' DIGSUM = DIGSUM + ( FIRST * 2 ). DIGREST = DIGSUM MOD 11. IF DIGREST = 0 OR DIGREST = 1. SECOND = 0. ELSE. SECOND = 11 - DIGREST. ENDIF. * same as before NFIRST = FIRST. NSECOND = SECOND. CONCATENATE AUX NFIRST NSECOND INTO CGC_NUMBER.