Recent

Author Topic: Barcode 128  (Read 9565 times)

mario9000

  • Newbie
  • Posts: 2
Barcode 128
« on: October 16, 2011, 05:38:38 pm »
I need a Code 128 barcode in CodeC and CodeB mode.

I get it but it cant be decoded.

Letter 1-2 are in CodeB     ( RR)
Number 3-10 in CodeC      ( 12345678 )
Letter 11-16 are in CodeB ( 5DE200 )

(Mail-Tracking specification)


Cane anybody help me?

Code: [Select]
  // Start mit B
  vChecksum := 104;
  result := Convert(StartB);    // Startcode

  debug.add(FloatToStr(vChecksum) + ' - Start');

  idx := Find_Code128AB(FText[1]);                           // 1 Buchstabe
  result := result + Convert(tabelle_128[idx].data);
  Inc(vChecksum, idx*1);

  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum));


  idx := Find_Code128AB(FText[2]);                           // 2 Buchstabe
  result := result + Convert(tabelle_128[idx].data);
  Inc(vChecksum, idx*2);

  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum));

  idx := 105;                                                // Code C
  result := result + Convert(StartC);
  Inc(vChecksum, idx*3);

  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum) + ' C ');

  idx := StrToInt(FText[3]+FText[4]);                      // 3+4 Zahlen
  result := result + Convert(tabelle_128[idx].data);
  Inc(vChecksum, idx*4);

  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum));

  idx := StrToInt(FText[5]+FText[6]);                      // 5+6 Zahlen
  result := result + Convert(tabelle_128[idx].data);
  Inc(vChecksum, idx*5);

  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum));

  idx := StrToInt(FText[7]+FText[8]);                      // 7+8  Zahlen
  result := result + Convert(tabelle_128[idx].data);
  Inc(vChecksum, idx*6);

  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum));

  idx := StrToInt(FText[9]+FText[10]);                     // 9+10  Zahlen
  result := result + Convert(tabelle_128[idx].data);
  Inc(vChecksum, idx*7);

  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum));

  idx := 104;                                                // Code B
  result := result + Convert(StartB);
  Inc(vChecksum, idx*8);
  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum) + ' B ');

  for i := 11 to 16 do // RR
     begin
       idx := Find_Code128AB(FText[i]);
       if idx < 0 then
          idx := Find_Code128AB(' ');
       result := result + Convert(tabelle_128[idx].data);
       Inc(vChecksum, idx*(i-2));
  debug.add(FloatToStr(idx) + ' - ' + FloatToStr(vChecksum));
     end;

  vChecksum := vChecksum mod 103;
  result := result + Convert(tabelle_128[vChecksum].data);

  debug.add(FloatToStr(vChecksum) + ' - Prüf');

  result := result + Convert(Stop);      // Stopcode
  debug.add('Stop'); 
« Last Edit: October 16, 2011, 05:40:54 pm by mario9000 »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Barcode 128
« Reply #1 on: October 16, 2011, 07:57:42 pm »
What components are you using? I seem to remember an error with some barcode component when using the letter i (I think); you might have some luck searching the forum.

(No experience with barcodes myself though)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

mario9000

  • Newbie
  • Posts: 2
Re: Barcode 128
« Reply #2 on: October 16, 2011, 09:10:09 pm »
I've edit
C:\lazarus\components\lazreport\source\barcode.pas
to enable the switch between the code set while the creating.

The problem was that i use the "Start C" command and not the switch command.

It warks with:
Code: [Select]
  idx := 99;                                                // Code C
  result := result + Convert(tabelle_128[idx].data);
  Inc(vChecksum, idx*3);     

eddiecook

  • Newbie
  • Posts: 3
Re: Barcode 128
« Reply #3 on: March 27, 2013, 03:23:40 am »
I think you may need to read this sentence carefully. It talks about the Code set shift issues of Code 128.

This change applies to all characters following the Code Set character until either the end of the symbol, another Code Set
character or the Shift character is encountered. (cite from ISO/IEC 15417:2007(E)8 ).




Tags: Code 128

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7507
Re: Barcode 128
« Reply #4 on: July 11, 2013, 09:53:23 am »
There are several free and paid for Lazarus and Delphi solutions that will probably be easier than porting/interfacing .NET components

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: Barcode 128
« Reply #5 on: August 14, 2013, 08:49:12 am »
Maybe this font could help:
http://www.jtbarton.com/Barcodes/Code128.aspx

or this Delphi component:
http://www.torry.net/vcl/misc/barcodes/fbarcode.zip

TurboPower SysTools for Delphi has barcode 128:
https://sourceforge.net/projects/tpsystools

There was an effort to convert SysTools Kylix version to Lazarus but barcode part was not included because of QT dependecies (which do not exist in non-Kylix version):
http://wiki.freepascal.org/FpSystools
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib