home *** CD-ROM | disk | FTP | other *** search
- // Code 93
- Unit Kod8;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls,
- U;
-
- procedure HC8(var Co:TMemo);
- procedure S2L8(Co:String; StartStop:Boolean; Crc:Boolean ; var Raw:String; var RawS:String; var Bits:String);
-
-
- implementation
-
- const MaxKod=47;
- var Kody:Array[0..48]of record
- Asc:String;
- Kod:Byte;
- Line:String;
- end;
-
- procedure HC8(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 S2L8(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+(Length(Raw)-I+1)*Ord(Raw[I]);
- end;
- Raw:=Raw+Chr(J mod 47);
-
- J:=0;
- for I:=1 to Length(Raw) do
- begin
- J:=J+(Length(Raw)-I+1)*Ord(Raw[I]);
- end;
- Raw:=Raw+Chr(J mod 47);
- end;
-
- if StartStop then Raw:=#47+Raw+#48;
- //// 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) 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:='131112';end;
- with Kody[01]do begin Asc:='1';Kod:=1;Line:='111213';end;
- with Kody[02]do begin Asc:='2';Kod:=2;Line:='111312';end;
- with Kody[03]do begin Asc:='3';Kod:=3;Line:='111411';end;
- with Kody[04]do begin Asc:='4';Kod:=4;Line:='121113';end;
- with Kody[05]do begin Asc:='5';Kod:=5;Line:='121212';end;
- with Kody[06]do begin Asc:='6';Kod:=6;Line:='121311';end;
- with Kody[07]do begin Asc:='7';Kod:=7;Line:='111114';end;
- with Kody[08]do begin Asc:='8';Kod:=8;Line:='131211';end;
- with Kody[09]do begin Asc:='9';Kod:=9;Line:='141111';end;
-
- with Kody[10]do begin Asc:='A';Kod:=10;Line:='211113';end;
- with Kody[11]do begin Asc:='B';Kod:=11;Line:='211212';end;
- with Kody[12]do begin Asc:='C';Kod:=12;Line:='211311';end;
- with Kody[13]do begin Asc:='D';Kod:=13;Line:='221112';end;
- with Kody[14]do begin Asc:='E';Kod:=14;Line:='221211';end;
- with Kody[15]do begin Asc:='F';Kod:=15;Line:='231111';end;
- with Kody[16]do begin Asc:='G';Kod:=16;Line:='112113';end;
- with Kody[17]do begin Asc:='H';Kod:=17;Line:='112212';end;
- with Kody[18]do begin Asc:='I';Kod:=18;Line:='112311';end;
- with Kody[19]do begin Asc:='J';Kod:=19;Line:='122112';end;
-
- with Kody[20]do begin Asc:='K';Kod:=20;Line:='132111';end;
- with Kody[21]do begin Asc:='L';Kod:=21;Line:='111123';end;
- with Kody[22]do begin Asc:='M';Kod:=22;Line:='111222';end;
- with Kody[23]do begin Asc:='N';Kod:=23;Line:='111321';end;
- with Kody[24]do begin Asc:='O';Kod:=24;Line:='121122';end;
- with Kody[25]do begin Asc:='P';Kod:=25;Line:='131121';end;
- with Kody[26]do begin Asc:='Q';Kod:=26;Line:='212112';end;
- with Kody[27]do begin Asc:='R';Kod:=27;Line:='212211';end;
- with Kody[28]do begin Asc:='S';Kod:=28;Line:='211122';end;
- with Kody[29]do begin Asc:='T';Kod:=29;Line:='211221';end;
-
- with Kody[30]do begin Asc:='U';Kod:=30;Line:='221121';end;
- with Kody[31]do begin Asc:='V';Kod:=31;Line:='222111';end;
- with Kody[32]do begin Asc:='W';Kod:=32;Line:='112122';end;
- with Kody[33]do begin Asc:='X';Kod:=33;Line:='112221';end;
- with Kody[34]do begin Asc:='Y';Kod:=34;Line:='122121';end;
- with Kody[35]do begin Asc:='Z';Kod:=35;Line:='123111';end;
- with Kody[36]do begin Asc:='-';Kod:=36;Line:='121131';end;
- with Kody[37]do begin Asc:='.';Kod:=37;Line:='311112';end;
- with Kody[38]do begin Asc:=' ';Kod:=38;Line:='311211';end;
- with Kody[39]do begin Asc:='$';Kod:=39;Line:='321111';end;
-
- with Kody[40]do begin Asc:='/';Kod:=40;Line:='112131';end;
- with Kody[41]do begin Asc:='+';Kod:=41;Line:='113121';end;
- with Kody[42]do begin Asc:='%';Kod:=42;Line:='211131';end;
- with Kody[43]do begin Asc:='{_$}';Kod:=43;Line:='121221';end;
- with Kody[44]do begin Asc:='{_%}';Kod:=44;Line:='312111';end;
- with Kody[45]do begin Asc:='{_/}';Kod:=45;Line:='311121';end;
- with Kody[46]do begin Asc:='{_+}';Kod:=46;Line:='122211';end;
- with Kody[47]do begin Asc:='{Start}';Kod:=47;Line:='111141';end;
- with Kody[48]do begin Asc:='{Stop}';Kod:=48;Line:='1111411';end;
- end.
-