New call-to-action
Results 1 to 8 of 8

Thread: Checksum Algorithm for Code128

  1. #1
    Ed
    Guest

    Default Checksum Algorithm for Code128

    Has anyone ever written an Xbasic script for calculating Modulo 103 checksums on Code128 barcodes? If you have and wouldn't minde sharing the code, I'd be grateful. If you can pint me in the right direction, that would be nice too.

    Searching produced no results, and the checksum function in A5 v5/6 doesn't do Mod103.

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Checksum Algorithm for Code128

    I did something way long ago that's in the code archive, search for code 128. If I remember correctly I only implemented it for an even number of characters in the input string as I was working with encoding twelve digit upc numbers.

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Checksum Algorithm for Code128

    And I just adapted this from something I found on the net.

    FUNCTION cksm128 AS C (input_string AS C )
    '*
    '* Initialize running total with value of start character, then scan the
    '* string and add character value times position
    '*
    SUBTOT = 104
    FOR I = 1 TO LEN(input_string)
    C = SUBSTR(input_string, I, 1)
    X = asc(C) - 32
    SUBTOT = SUBTOT + (X * I)
    NEXT I
    '*
    '* Calculate Modulo 103. This is the checksum
    '*
    cksm128= MOD(SUBTOT,103)
    '*
    '* Now convert numeric checksum to a character. This conversion takes
    '* into account the particular mapping of the font being used (this
    '* example is for the font published by Azalea Software).
    '*
    ''select CASE
    '' CASE CHKDIG = 0
    '' CHKCHR = CHR(174)
    '' CASE CHKDIG " 94
    '' CHKCHR = CHR(CHKDIG + 32)
    '' OTHERWISE
    '' CHKCHR = CHR(CHKDIG + 71)
    ''ENDCASE
    ''*
    ''* Now format the final output string: start character,
    ''* data, check character, and stop character.
    ''*
    ''OUTSTRING = CHR(162) + MYSTRING + CHKCHR + CHR(164)
    END FUNCTION


    I left in some other parts than the checksum "value" which you might be able to use. Usage is

    ? cksm128("BarCode 1")
    = "33"

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Checksum Algorithm for Code128

    The function in the archive is limited to subset C while I think this one handles B and C.

  5. #5
    Ed
    Guest

    Default RE: Checksum Algorithm for Code128

    Stan:

    Thanks for your help. This will get me started.

  6. #6
    Member
    Real Name
    Paul Benson
    Join Date
    Jan 2010
    Location
    NC
    Posts
    1

    Default Re: Checksum Algorithm for Code128

    I notice that the checksum formula states the the Code 128 start character is 104 and the value of 104 is used in calculating the checksum. Why does the routine then use CHR(162) as the start character instead of CHR(104) ?

    I am having trouble generating readable code128 barcodes in some cases.

    I have also seen this checksum calculation shown as

    if 0 then 194
    else if < 64 then +32
    else +100

    instead of

    if 0 then 174
    ekse uf < 64 then +32
    else +71

    Why are there two different formulas?

    Any help would be appreciated.

    Thanks.

    Paul

  7. #7
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Checksum Algorithm for Code128

    '* Now convert numeric checksum to a character. This conversion takes
    '* into account the particular mapping of the font being used
    (this
    '* example is for the font published by Azalea Software).
    There can be only one.

  8. #8
    Member
    Real Name
    Bobert Anderson
    Join Date
    Nov 2012
    Posts
    5

    Default Re: Checksum Algorithm for Code128

    I think this passage concerning generating Code 128 barcodes in .NET may be helpful.

Similar Threads

  1. Barcoding code128
    By Stan Mathews in forum Code Archive
    Replies: 13
    Last Post: 11-29-2016, 02:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •