home *** CD-ROM | disk | FTP | other *** search
- // Code 2/5 Invert
- Unit Kod5;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls,
- U;
-
- procedure HC5(var Co:TMemo);
- procedure S2L5(Co:String; StartStop:Boolean; Crc:Boolean ; var Raw:String; var RawS:String; var Bits:String);
-
-
- implementation
-
- const MaxKod=11;
- var Kody:Array[0..11]of record
- Asc:String;
- Kod:Byte;
- Line:String;
- end;
-
- procedure HC5(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 S2L5(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
- //// 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 10);
- end;
-
- if StartStop then Raw:=#10+Raw+#11;
- //// 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:=$30; // 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;
- Bits:='11111111'+Bits+'11111111';
- end;
-
- begin
- with Kody[00]do begin Asc:='0';Kod:=0;Line:='0000101000';end;
- with Kody[01]do begin Asc:='1';Kod:=1;Line:='1000000010';end;
- with Kody[02]do begin Asc:='2';Kod:=2;Line:='0010000010';end;
- with Kody[03]do begin Asc:='3';Kod:=3;Line:='1010000000';end;
- with Kody[04]do begin Asc:='4';Kod:=4;Line:='0000100010';end;
- with Kody[05]do begin Asc:='5';Kod:=5;Line:='1000100000';end;
- with Kody[06]do begin Asc:='6';Kod:=6;Line:='0010100000';end;
- with Kody[07]do begin Asc:='7';Kod:=7;Line:='0000001010';end;
- with Kody[08]do begin Asc:='8';Kod:=8;Line:='1000001000';end;
- with Kody[09]do begin Asc:='9';Kod:=9;Line:='0010001000';end;
- with Kody[10]do begin Asc:='{Start}';Kod:=10;Line:='101000';end;
- with Kody[11]do begin Asc:='{Stop}';Kod:=11;Line:='100010';end;
- end.
-