Pages

Friday, 7 June 2013

BarCode Interleaved 2of5 Check Digit Coding


Check Digit
A check digit can be used to mathematically verify that the bar code data is correct. With Interleaved 2 of 5 the check digit is optional, but if desired a Modulo 10 with weighting of 3, 1, 3 is used. The string must always be an even number of characters, so if the addition of a check digit gives an odd number, a zero should be added to the beginning of the string.

Note: the check digit is designated as Modulo 10, but is in fact a surplus to the number 10. Mathematically speaking, Modulo 10 is the remainder of the sum when the total is divided by 10.

Beginning with the left-most digit in the string, alternately multiply each number by 3 then 1 then 3 etc.

Data digit sequence 1 2 3 4 5 6 7 8 9 0
Weighting factor (multiply) 3 1 3 1 3 1 3 1 3 1
Total 3 2 9 4 15 6 21 8 27 0 = 95
The check digit is the digit needed to be added to the sum to make it an even multiple of 10. In this case the check digit is 5.
START 0 1 2 3 4 5 6 7 8 9 0 5 STOP
Modulo 10 (Weighting 3)

Variables:

Name                                    DataType             Subtype               Length

Val1                                       Integer       
Val2                                       Integer                
Val3                                       Integer                
Val4                                       Integer                
Val5                                       Integer                
Val6                                       Integer                
Val7                                       Integer                
Val8                                       Integer                
Val9                                       Integer                
Val10                                     Integer                
Val11                                     Integer                
Val12                                     Integer                
Val13                                     Integer                
Val14                                     Integer                
Val15                                     Integer                
Value                                    Integer                
data                                       Integer                

TxtVal1                                 Text                       30
TxtVal2                                 Text                       30
TxtVal3                                 Text                       30
TxtVal4                                 Text                       30
TxtVal5                                 Text                       30
TxtVal6                                 Text                       30
TxtVal7                                 Text                       30
TxtVal8                                 Text                       30
TxtVal9                                 Text                       30
TxtVal10                               Text                       30
TxtVal11                               Text                       30
TxtVal12                               Text                       30
TxtVal13                               Text                       30
TxtVal14                               Text                       30
TxtVal15                               Text                       30

Value1                                  Text                       30
TValue                                  Integer                

TxtValue                              Text                       30

InputL                                   Text                       30

Coding :

InputL := Input ;
Value1 := COPYSTR(InputL,1,STRLEN(InputL));

Note: dividing string as a indivisible parts

TxtVal1 := COPYSTR(Value1,1,1);
TxtVal2 := COPYSTR(Value1,2,1);
TxtVal3 := COPYSTR(Value1,3,1);
TxtVal4 := COPYSTR(Value1,4,1);
TxtVal5 := COPYSTR(Value1,5,1);
TxtVal6 := COPYSTR(Value1,6,1);
TxtVal7 := COPYSTR(Value1,7,1);
TxtVal8 := COPYSTR(Value1,8,1);
TxtVal9 := COPYSTR(Value1,9,1);
TxtVal10 := COPYSTR(Value1,10,1);
TxtVal11 := COPYSTR(Value1,11,1);
TxtVal12 := COPYSTR(Value1,12,1);

Note: convert text as a integer.

EVALUATE(Val1,TxtVal1);
EVALUATE(Val2,TxtVal2);
EVALUATE(Val3,TxtVal3);
EVALUATE(Val4,TxtVal4);
EVALUATE(Val5,TxtVal5);
EVALUATE(Val6,TxtVal6);
EVALUATE(Val7,TxtVal7);
EVALUATE(Val8,TxtVal8);
EVALUATE(Val9,TxtVal9);
EVALUATE(Val10,TxtVal10);
EVALUATE(Val11,TxtVal11);
EVALUATE(Val12,TxtVal12);

Note: Odd number multiply with 3 and even number multiply with 1.

Val1 := Val1 * 3;
Val2 := Val2 * 1;
Val3 := Val3 * 3;
Val4 := Val4 * 1;
Val5 := Val5 * 3;
Val6 := Val6 * 1;
Val7 := Val7 * 3;
Val8 := Val8 * 1;
Val9 := Val9 * 3;
Val10 := Val10 * 1;
Val11 := Val11 * 3;
Val12 := Val12 * 1;

 TValue := Val1 + Val2 + Val3 + Val4 + Val5 + Val6 + Val7 + Val8 + Val9 + Val10 + Val11 + Val12;

 TValue := TValue MOD 10;
IF TValue <> 0 THEN
   TValue :=10 - TValue
ELSE
   TValue := 0;

TxtValue := FORMAT(TValue);
OutPut:=TxtValue;

No comments:

Post a Comment