EAN128. What the???
Although RB supports Code128, trying to get it to support EAN128 has caused
me all sorts of dramas. I have seen the standard RB response when people ask
about EAN128 (I've posted below for reference).
With regard to point 1, that link takes you to a page which shows the USS
Code-128 Character Set. They show Start A as being #203, but in the RB help
files in the section on Manually Encoding Data for Code 128, Start A is
#208. In fact, for all of these function codes, all the RB Codes are +5
higher than the ones shown on this web page (another page
http://grandzebu.net/informatique/codbar-en/code128.htm also uses #203 for
Start A). Why are the RB codes different?
With regards to point 2, I have AutoEncode set to False. Sometimes I can set
a value to Data and its ok. Othertimes I can set Data to a value and it RB
displays an message box with an empty message. So it appears to still be
doing some sort of encoding/check anyway. What's going on? I think what is
happening is that I was using Character set C which seems to require an even
number of numbers. Character Set A seems to be more successful. A nicer
error message would have saved me a lot of time.
After several hours of struggling and going by a very torturous route, I
finally seem to have been able to print EAN128 barcodes with multiple
segments separated by FNC1 by doing something like this:
ppBarcode1.AutoEncode := False;
ppBarcode1.Data := #208#207+'01121221'+#207+'17060310'; //#208= Start A,
#207=FNC1
So damn simple. Couldn't you have included something like that in your
TechTips? I could have gone to be about three hours ago! :-) It seems to
print and scan correctly. One interesting side effect though is that Char
Set A is supposed to support uppercase characters only. But when it scans
they show in lowercase.
Char Set C does give a much more compressed barcode. If you can use numbers
and if you make sure each segment has an even number of digits (it doesn't
seem to matter if the overall length is even, each segments seems to need to
be even), then you should use Set C like this:
ppBarcode1.AutoEncode := False;
ppBarcode1.Data := #210#207+'01121221'+#207+'17060310'; //#210= Start C,
#207=FNC1
Hopefully others will find this useful.
Regards
Jeff
--------------------------------------------------------
Tech Tip: UCC/EAN 128 Barcode Generation
--------------------------------------------------------
ReportBuilder's support for the Code 128 barcode symbology can be used to
print UCC\EAN 128 barcodes.
Code 128 is general purpose symbology that can be used to generate UCC/EAN
128 barcodes.
1. Here is a link that came up when I searched in Google. It is for another
barcode product, but it explains the symbology.
http://www.idautomation.com/code128faq.html#EAN128andUCC128
2. The TppBarCode component contains an AutoEncode property that defaults to
True. To support UCC/EAN 128 you will need set AutoEncode to False and
manually encode the data. See the AutoEncode topic in the RBuilder.hlp. From
there you can access a related topic on manually encoding Code 128 data.
me all sorts of dramas. I have seen the standard RB response when people ask
about EAN128 (I've posted below for reference).
With regard to point 1, that link takes you to a page which shows the USS
Code-128 Character Set. They show Start A as being #203, but in the RB help
files in the section on Manually Encoding Data for Code 128, Start A is
#208. In fact, for all of these function codes, all the RB Codes are +5
higher than the ones shown on this web page (another page
http://grandzebu.net/informatique/codbar-en/code128.htm also uses #203 for
Start A). Why are the RB codes different?
With regards to point 2, I have AutoEncode set to False. Sometimes I can set
a value to Data and its ok. Othertimes I can set Data to a value and it RB
displays an message box with an empty message. So it appears to still be
doing some sort of encoding/check anyway. What's going on? I think what is
happening is that I was using Character set C which seems to require an even
number of numbers. Character Set A seems to be more successful. A nicer
error message would have saved me a lot of time.
After several hours of struggling and going by a very torturous route, I
finally seem to have been able to print EAN128 barcodes with multiple
segments separated by FNC1 by doing something like this:
ppBarcode1.AutoEncode := False;
ppBarcode1.Data := #208#207+'01121221'+#207+'17060310'; //#208= Start A,
#207=FNC1
So damn simple. Couldn't you have included something like that in your
TechTips? I could have gone to be about three hours ago! :-) It seems to
print and scan correctly. One interesting side effect though is that Char
Set A is supposed to support uppercase characters only. But when it scans
they show in lowercase.
Char Set C does give a much more compressed barcode. If you can use numbers
and if you make sure each segment has an even number of digits (it doesn't
seem to matter if the overall length is even, each segments seems to need to
be even), then you should use Set C like this:
ppBarcode1.AutoEncode := False;
ppBarcode1.Data := #210#207+'01121221'+#207+'17060310'; //#210= Start C,
#207=FNC1
Hopefully others will find this useful.
Regards
Jeff
--------------------------------------------------------
Tech Tip: UCC/EAN 128 Barcode Generation
--------------------------------------------------------
ReportBuilder's support for the Code 128 barcode symbology can be used to
print UCC\EAN 128 barcodes.
Code 128 is general purpose symbology that can be used to generate UCC/EAN
128 barcodes.
1. Here is a link that came up when I searched in Google. It is for another
barcode product, but it explains the symbology.
http://www.idautomation.com/code128faq.html#EAN128andUCC128
2. The TppBarCode component contains an AutoEncode property that defaults to
True. To support UCC/EAN 128 you will need set AutoEncode to False and
manually encode the data. See the AutoEncode topic in the RBuilder.hlp. From
there you can access a related topic on manually encoding Code 128 data.
This discussion has been closed.
Comments
Thanks for the info. I will see about making this into a tech tip article.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
are different to others, e.g. why #208 instead of #203?
Thanks
Jeff
Thanks for the feedback
In all honesty our knowledge of barcode symbologies is lacking.
The RB barcode components originated as a stand alone barcode component that
we acquired from another company. The original developer of the component
was very much an expert in barcodes and had tested the barcode output with a
variety of barcode readers.
We honestly do not know the answer to that question.
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
numbers are different either but the barcodes seem to work as expected. A
bit weird, me thinks.
that all goods going to Proctor and Gamble MUST be encoded using UCC-EAN128
I actually started looking at this back in May 2005, We used your example
and now have it working.
MANY MANY Thanks
Colin
Me thinks this does need attention !, i wonder do Digital_M actually have
the source code, because finding that stupid empty error message should be a
number 1 priority .
button and a report on a form,
Enjoy....
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ppPrnabl, ppClass, ppCtrls, ppBarCod, ppBands, ppCache, ppComm,
ppRelatv, ppProd, ppReport, pptypes, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ppReport1: TppReport;
ppHeaderBand1: TppHeaderBand;
ppDetailBand1: TppDetailBand;
ppFooterBand1: TppFooterBand;
ppBarCode1: TppBarCode;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function PadLeft(s:string;iWidth:integer;cPad:char):string;
procedure GenCode(var sCode,sHuman:string;
sAppId,sExt,sComp:string;iId:integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
sCode : string;
sHuman : string;
begin
ppbarcode1.AutoEncode := false;
GenCode(sCode,sHuman,'00','3','4006625',71305977);
showmessage(sCode);
///showmessage(sHuman);
ppBarcode1.Data := sCode;
///ppBarCode1.PrintHumanReadable := true;
ppreport1.DeviceType := dtscreen;
ppreport1.Print;
end;
const
KFNC1 = chr(207);
KSTART = chr(210);
procedure TForm1.GenCode(var sCode,sHuman:string;
sAppId,sExt,sComp:string;iId:integer);
var
iCheck : integer;
i : integer;
c : char;
sPaddedComp : string;
sPaddedId : string;
iOdd : integer;
iEven : integer;
iC : integer;
begin
sPaddedComp := PadLeft(sComp,7,'0');
sPaddedId := PadLeft(IntToStr(iId),9,'0');
sCode := KSTART + KFNC1 + sAppId + sExt + sPaddedComp + sPaddedID;
sHuman := '(' + sAppId + ') ' + sExt + ' ' + sPaddedComp + ' ' +
sPaddedID;
iOdd := 0;
iEven := 0;
////showmessage('Length ' + IntTosTr(Length(sCode)));
for i := 3 to 21 do
begin
c := sCode[i];
iC := StrToInt(c);
if Odd(i) then
Inc(iOdd,iC)
else
Inc(iEven,iC);
end;
iOdd := iOdd * 3;
iCheck := iEven + (iOdd * 3);
iCheck :=iCheck mod 10;
sCode := sCode + IntToStr(iCheck);
sHuman := sHuman + ' ' + IntToStr(iCheck)
end;
function TForm1.PadLeft(s: string; iWidth: integer;cPad:char): string;
var
sResult : string;
begin
sResult := s;
while length(sResult) < iWidth do
sResult := cPad + sResult;
Result := sResult
end;
end.
I haven't been on the newsgroup recently. I just read your post and come
back looking for this one to refer you to it. But you had already found it!
I'm glad I shortened some one elses frustration with the damn EAN128 stuff!
Cheers
Jeff