home *** CD-ROM | disk | FTP | other *** search
- // Code 39 (Standard)
- Unit Kod6;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls,
- U;
-
- procedure HC6(var Co:TMemo);
- procedure S2L6(Co:String; StartStop:Boolean; Crc:Boolean ; var Raw:String; var RawS:String; var Bits:String);
-
-
- implementation
-
- const MaxKod=43;
- var Kody:Array[0..43]of record
- Asc:String;
- Kod:Byte;
- Line:String;
- end;
-
- procedure HC6(var Co:TMemo);
- var I:Word;
- begin
- Co.Clear;
- for I:=0 to MaxKod do
- with Kody[I] do
- begin
- Co.Lines.Add(Hex(Kod)+' '+Asc+' ('+Line+')');
- end;
- end;
-
- procedure S2L6(Co:String; StartStop:Boolean; Crc:Boolean ; var Raw:String; var RawS:String; var Bits:String);
- var I,J,K:Integer;
- Pom,Pom2:String;
- PomC:Byte;
- E:Integer;
- Ch:Byte;
- begin
- Raw:='';
- RawS:='';
- Bits:='';
- if Length(Co)=0 then Exit;
- //// Vy°a∩ neplatnΘ a zkonvertuj HEX verze
- I:=1;
- while I<=Length(Co) do
- begin
- Co[I]:=UpCase(Co[I]);
- //// Je to $ ?
- if Co[I]='$' then // Je to HEX
- begin
- Pom:='';
- repeat
- Pom:=Pom+Co[I];
- I:=I+1; // Posu≥ o dalÜφ znak
- until (length(Pom)=3) or (I>Length(Co));
- if I<=Length(Co) then I:=I-1;
- Val(Pom,PomC,E);
- if (E=0)and(PomC<=MaxKod) then
- begin
- Raw:=Raw+Chr(PomC);
- end;
- end else
- begin // Nenφ to HEX
- for J:=0 to MaxKod do
- if Co[I]=Kody[J].Asc then Raw:=Raw+Chr(Kody[J].Kod);
- end;
- I:=I+1;
- end;
- //// Crc a Start/Stop
- if Crc then
- begin
- J:=0;
- for I:=1 to Length(Raw) do
- begin
- J:=J+Ord(Raw[I]);
- end;
- Raw:=Raw+Chr(J mod 43);
- end;
-
- if StartStop then Raw:=#39+Raw+#39;
- //// Na zobrazitelne
- //// +Na bity
- for I:=1 to Length(Raw) do
- begin
- RawS:=RawS+Kody[Ord(Raw[I])].Asc;
- Pom2:=Kody[Ord(Raw[I])].Line;
- Pom:='';
- Ch:=$31; // ZaΦφnßme jedniΦkou
- for J:=1 to Length(Pom2) do
- begin
- for K:=1 to (Ord(Pom2[J])-$30+1) do // Pozor na 0-x a 1-x v tabulce bit∙ !!!
- begin
- Pom:=Pom+Chr(Ch);
- end;
- Ch:=Ch xor 1;
- end;
- Bits:=Bits+Pom;
- end;
- end;
-
- begin
- with Kody[00]do begin Asc:='0';Kod:=0;Line:='0001101000';end;
- with Kody[01]do begin Asc:='1';Kod:=1;Line:='1001000010';end;
- with Kody[02]do begin Asc:='2';Kod:=2;Line:='0011000010';end;
- with Kody[03]do begin Asc:='3';Kod:=3;Line:='1011000000';end;
- with Kody[04]do begin Asc:='4';Kod:=4;Line:='0001100010';end;
- with Kody[05]do begin Asc:='5';Kod:=5;Line:='1001100000';end;
- with Kody[06]do begin Asc:='6';Kod:=6;Line:='0011100000';end;
- with Kody[07]do begin Asc:='7';Kod:=7;Line:='0001001010';end;
- with Kody[08]do begin Asc:='8';Kod:=8;Line:='1001001000';end;
- with Kody[09]do begin Asc:='9';Kod:=9;Line:='0011001000';end;
-
- with Kody[10]do begin Asc:='A';Kod:=10;Line:='1000010010';end;
- with Kody[11]do begin Asc:='B';Kod:=11;Line:='0010010010';end;
- with Kody[12]do begin Asc:='C';Kod:=12;Line:='1010010000';end;
- with Kody[13]do begin Asc:='D';Kod:=13;Line:='0000110010';end;
- with Kody[14]do begin Asc:='E';Kod:=14;Line:='1000110000';end;
- with Kody[15]do begin Asc:='F';Kod:=15;Line:='0010110000';end;
- with Kody[16]do begin Asc:='G';Kod:=16;Line:='0000011010';end;
- with Kody[17]do begin Asc:='H';Kod:=17;Line:='1000011000';end;
- with Kody[18]do begin Asc:='I';Kod:=18;Line:='0010011000';end;
- with Kody[19]do begin Asc:='J';Kod:=19;Line:='0000111000';end;
-
- with Kody[20]do begin Asc:='K';Kod:=20;Line:='1000000110';end;
- with Kody[21]do begin Asc:='L';Kod:=21;Line:='0010000110';end;
- with Kody[22]do begin Asc:='M';Kod:=22;Line:='1010000100';end;
- with Kody[23]do begin Asc:='N';Kod:=23;Line:='0000100110';end;
- with Kody[24]do begin Asc:='O';Kod:=24;Line:='1000100100';end;
- with Kody[25]do begin Asc:='P';Kod:=25;Line:='0010100100';end;
- with Kody[26]do begin Asc:='Q';Kod:=26;Line:='0000001110';end;
- with Kody[27]do begin Asc:='R';Kod:=27;Line:='1000001100';end;
- with Kody[28]do begin Asc:='S';Kod:=28;Line:='0010001100';end;
- with Kody[29]do begin Asc:='T';Kod:=29;Line:='0000101100';end;
-
- with Kody[30]do begin Asc:='U';Kod:=30;Line:='1100000010';end;
- with Kody[31]do begin Asc:='V';Kod:=31;Line:='0110000010';end;
- with Kody[32]do begin Asc:='W';Kod:=32;Line:='1110000000';end;
- with Kody[33]do begin Asc:='X';Kod:=33;Line:='0100100010';end;
- with Kody[34]do begin Asc:='Y';Kod:=34;Line:='1100100000';end;
- with Kody[35]do begin Asc:='Z';Kod:=35;Line:='0110100000';end;
- with Kody[36]do begin Asc:='-';Kod:=36;Line:='0100001010';end;
- with Kody[37]do begin Asc:='.';Kod:=37;Line:='1100001000';end;
- with Kody[38]do begin Asc:=' ';Kod:=38;Line:='0110001000';end;
- with Kody[39]do begin Asc:='*';Kod:=39;Line:='0100101000';end;
-
- with Kody[40]do begin Asc:='$';Kod:=40;Line:='0101010000';end;
- with Kody[41]do begin Asc:='/';Kod:=41;Line:='0101000100';end;
- with Kody[42]do begin Asc:='+';Kod:=42;Line:='0100010100';end;
- with Kody[43]do begin Asc:='%';Kod:=43;Line:='0001010100';end;
- end.
-