11 Replies Latest reply on Jun 13, 2017 8:29 AM by michaelkirwan

    Decoding 128 barcode checkdigit

    michaelkirwan

      Hi All

      I want to validate a 128 check digit in filemaker. RL549737982IE is an example of one such barcode. I know the check digit is the 2 (RL549737982IE).

      can anyone explain how this number is derived at?.

       

      I have tried every combination of ACCII characters I could thing of and I cant resolve it.

       

      Regards ..... Mike

        • 1. Re: Decoding 128 barcode checkdigit
          jbante

          First, why do you want to validate a Code 128 check digit with FileMaker? We normally like to configure scanners to not include the metadata about the scan before and after the data stream — just the encoded data. Then it's up to the scanner to validate the check character, and to not give us any data if it doesn't check out.

           

          Further, you can't actually validate a Code 128 check character using only the encoded data. The same data can often be encoded in Code 128 more than one way. The calculation for the check character depends on what decisions were made in how to encode the data — information that is not available from the decoded data (or in the data about to be encoded).

           

          When you say that you've tried several characters and that you haven't manage to resolve the issue, how do you know that you don't have the wrong answer? Telling us about how you're testing might give us a better idea exactly what you're trying to accomplish or lead to other solutions.

           

          What exactly is the data you're trying to validate? I wonder if maybe you're actually encoding data from some additional scheme that has its own check digit separate from Code 128. For example, if I encoded a UPC in a Code 128 barcode, the UPC data and the barcode would each have their own checksum. The scanner would validate the Code 128 check character transparently to my app, then I'd be able to validate the UPC check digit using the UPC scheme.

          2 of 2 people found this helpful
          • 2. Re: Decoding 128 barcode checkdigit
            mikebeargie

            Code 128 - Wikipedia

            Read the "Check Digit Calculation" section.

             

            Checking out the calculations used in this custom function:

            FileMaker Custom Function:cfCode128 ( pString; pCodeSet )

            may lead you to some greater understanding of how this is calculated using filemaker.

             

            This solution may also be useful to your efforts:

            FileMaker Pro Barcode Font Encoder Custom Functions

             

            And also:

            http://www.modularfilemaker.org/module/easybarcode/

             

            My advice? Look at the stuff above and see what you can borrow and make work for your validation needs. Much easier than trying to reverse engineer from the ground up just for validation.

            1 of 1 people found this helpful
            • 3. Re: Decoding 128 barcode checkdigit
              michaelkirwan

              Thanks for your input

              This is a mail identifier number. there are three start possibilities  "RL" "LL" "CL" then eight numbers, and a check digit and all the barcodes end in "IE" e.g. RL549737925IE. If some user needs to enter this manually and mistypes a number of digit, I wanted to run a script to validate they entered the correct number. Since the "IE" at the end is always the same and there are only 3 start possibilities, I am wondering if is only the digits which are which form the validation.

              So I tried variations the following are per instructions on numerous sites.

              Start             (104)

              No.  ACHII x Position

              5  =         (21 x1)            =  (21)

              4  =         (20 x2)            =  (40)

              9  =         (25 x3)            =  (75)

              7  =         (23 x4)            =  (92)

              3  =         (19 x5)            =  (95)

              7  =         (23 x6)            = (138)

              9  =         (25 x7)            = (175)

              2  =         (18 x8)            = (144)

               

              Sum                               = (884) mod 130 = 8 remainder 60 (nowhere near the 5 that should be the answer)

              Someone might know my mistake....

              I will check Mikes sites and see if they yield anything.... Thanks again

              • 4. Re: Decoding 128 barcode checkdigit
                michaelkirwan

                Thanks Mike

                This is a mail identifier number. there are three start possibilities  "RL" "LL" "CL" then eight numbers, and a check digit and all the barcodes end in "IE" e.g. RL549737925IE. If some user needs to enter this manually and mistypes a number of digit, I wanted to run a script to validate they entered the correct number. Since the "IE" at the end is always the same and there are only 3 start possibilities, I am wondering if is only the digits which are which form the validation.

                So I tried variations the following are per instructions on numerous sites.

                Start             (104)

                No.  ACHII x Position

                5  =         (21 x1)            =  (21)

                4  =         (20 x2)            =  (40)

                9  =         (25 x3)            =  (75)

                7  =         (23 x4)            =  (92)

                3  =         (19 x5)            =  (95)

                7  =         (23 x6)            = (138)

                9  =         (25 x7)            = (175)

                2  =         (18 x8)            = (144)

                 

                Sum                               = (884) mod 130 = 8 remainder 60 (nowhere near the 5 that should be the answer)

                Someone might know my mistake....

                I will check out your reference sites and see if they yield anything.... Thanks again

                • 5. Re: Decoding 128 barcode checkdigit
                  jbante

                  The format you're describing sounds like a separate ID scheme with it's own check digit separate from Code 128. Is it this ID scheme (S10)? Does the check digit calculation in §5.4 do the trick?

                  • 6. Re: Decoding 128 barcode checkdigit
                    bigtom

                    jbante wrote:

                     

                    The format you're describing sounds like a separate ID scheme with it's own check digit separate from Code 128. Is it this ID scheme (S10)? Does the check digit calculation in §5.4 do the trick?

                    I believe jbante has the correct answer for you here. Check digits are often a modulus calc. This works a similar way  with credit card number validation. Filemaker does have the mod( ) function which might be helpful. One of the many useful things I learned in math class.

                    • 7. Re: Decoding 128 barcode checkdigit
                      bigtom

                      This does work and will identify manual entry error in the number. You can build it as a custom function. Return 1 for valid and 0 for invalid. Be careful as some international post labels use Code128 and include the 9th digit.

                       

                      Let (

                      [

                      code=CodeField;

                      num=GetAsNumber ( code );

                      c1=Left ( num; 1 )*8;

                      c2=Middle ( num; 2; 1 )*6;

                      c3=Middle ( num; 3; 1 )*4;

                      c4=Middle ( num; 4; 1 )*2;

                      c5=Middle ( num; 5; 1 )*3;

                      c6=Middle ( num; 6; 1 )*5;

                      c7=Middle ( num; 7; 1 )*9;

                      c8=Right ( num; 1 )*7;

                      wsum=c1+c2+c3+c4+c5+c6+c7+c8;

                      r=11-Mod ( wsum ; 11 );

                      cd=Case ( r=10; 0; r=11; 5; r );

                      valid=Case ( 11-Right( num; 1 ) =r; 1; 0)

                      ];

                      valid

                      )

                      1 of 1 people found this helpful
                      • 8. Re: Decoding 128 barcode checkdigit
                        michaelkirwan

                        THANK YOU!!!!!! jbante....That formula does the trick.

                         

                        I am actually humbled that you and bigtom have spent your spare time researching the answer for me... I am overwhelmed.. honesty!  I am so appreciative. If your ever coming to Ireland... I buy you a few pints...

                        Well done... Mike

                        Image result for guinness

                        • 9. Re: Decoding 128 barcode checkdigit
                          michaelkirwan

                          THANK YOU!!!!!! Mike...I have the answer to my problem...I am so appreciative of you using your time to help me..  regards Mike

                          • 10. Re: Decoding 128 barcode checkdigit
                            michaelkirwan

                            THANK YOU!!!!!! bigtom....That formula does the trick and I have the answer..

                             

                            I am actually humbled that you and jbante have spent your spare time researching the answer for me... I am overwhelmed.. honesty!  I am so appreciative. If your ever you come to Ireland... I buy you a few pints...

                            Well done... MikeImage result for guinness

                            • 11. Re: Decoding 128 barcode checkdigit
                              michaelkirwan

                              And thanks for the custom function....!!!