home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 September
/
Chip_2002-09_cd1.bin
/
zkuste
/
delphi
/
kompon
/
d123456
/
STR_BIT.ZIP
/
32
/
skr
/
Unit3.pas
< prev
Wrap
Pascal/Delphi Source File
|
2001-06-26
|
3KB
|
129 lines
{*─αφφ√Θ ∞εΣ≤δⁿ Γ√∩εδφ σ≥ ε±φεΓφ≤■ ⌠≤φΩ÷Φ■ - ±Ω≡σ∞ßδΦ≡εΓαφΦσ*}
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Gauges,strbit32, Buttons;
procedure Peredach( N1FileIn, N1FileOut,NU1,Polin1,Period1:String);
type
TForm3 = class(TForm)
Gauge1: TGauge;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
ProcessExit:Boolean;
NFileIn, NFileOut,NU,Polin,Period:String;
implementation
uses Unit1;
{$R *.DFM}
procedure Peredach( N1FileIn,N1FileOut,NU1,Polin1,Period1:String);
begin
NFileIn :=N1FileIn;
NFileOut:=N1FileOut;
NU :=NU1;
Polin :=Polin1;
Period:=Period1;
end;
// ╧≡ε÷σΣ≤≡α ε±≥αφεΓΩΦ ∩≡ε÷σ±±α
procedure TForm3.BitBtn1Click(Sender: TObject);
begin
ProcessExit:=true;
Close;
end;
// ╧≡ε÷σΣ≤≡α ±Ω≡σ∞ßδΦ≡εΓαφΦ
procedure TForm3.BitBtn2Click(Sender: TObject);
Var Registr,Polinom : TStr_Bit;
FileIn, FileOut : TBitFile;
Bit,stbit,POS : byte;
j,i,raz: LongWord;
pr:int64;
begin
Label1.Visible:=False;
Gauge1.Visible:=true;
Bitbtn2.Visible:=false;
Bitbtn1.Visible:=true;
{ ┬√ΣσδσφΦσ ∩α∞ ≥Φ }
Registr := TStr_Bit.Create;
Polinom := TStr_Bit.Create;
FileIn := TBitFile.Create;
FileOut := TBitFile.Create;
ProcessExit:=False;
pr:=strtoint(Period);
Try
{ O≥Ω≡√≥Φσ ⌠αΘδεΓ}
FileIn.OpenBitFile(NFileIn,btOpenRead,bt8);
FileOut.OpenBitFile(NFileOut,btCreate, bt8);
{ ╙±≥αφεΓΩα φα≈αδⁿφεπε ±ε±≥ε φΦ ≡σπΦ±≥≡α ±Ω≡σ∞ßδσ≡α }
Registr.Init_Sim(NU);
{ ╧≡σεß≡ατεΓαφΦσ ∩εδΦφε∞α Φτ ±Φ∞Γεδⁿφεπε ΓΦΣα Γ ßΦ≥εΓ≤■ ∩σ≡σ∞σφφ≤■}
Polinom.Init_Sim(Polin);
raz:=FileIn.SizeOfFile; {╬∩≡σΣσδσφΦσ ≡ατ∞σ≡α ⌠αΦδα}
J:=0;I:=0;
Bit := FileIn.ReadBit; {╫≥σφΦσ ßΦ≥α}
// ÷ΦΩδ ±Ω≡σ∞ßδΦ≡εΓαφΦ
while bit<2 do
begin
Application.ProcessMessages; {╬ß≡α∙σφΦσ Ω ∩≡ε÷σΣ≤≡σ Γε Γ≡σ∞ ÷ΦΩδα,
∩≡σ≡√ΓαφΦσ. ╬±≥αφεΓΩα ∩≡ε÷σ±±α }
if ProcessExit then Break; { ╬±≥αφεΓΩα ∩≡ε÷σ±±α }
stbit:=Registr.ModReg(Polinom); {╤≤∞∞Φ≡εΓαφΦσ ∩ε ε≥ΓεΣα∞ ≡σπΦ±≥≡α}
POS:=(stbit+Bit) mod 2;
FileOut.WriteBit(POS); {╟α∩Φ±ⁿ ßΦ≥α}
Registr.BitDisplase(stbit);{╤ΣΓΦπ Φ τα∩Φ±ⁿ φ≤δσΓεπε ßΦ≥α Γ ≡σπΦ±≥≡}
Bit := Filein.ReadBit; {╫≥σφΦσ ±δσΣ≤■∙σπε ßΦ≥α}
inc(j);
inc(i);
if i=pr then
begin
Registr.Init_Sim(NU);
i:=0;
end;
Gauge1.Progress:=100*j div raz;
end;
Except on EfileBitError do {╬°ΦßΩα εß≡αßε≥ΩΦ ⌠αΘδα}
ShowMessage('╬°ΦßΩα εß≡αßε≥ΩΦ');
end;
{ ╟αΩ≡√≥Φσ εß≡αßα≥√Γασ∞√⌡ ⌠αΘδεΓ}
FileIn.CloseBitFile;
FileOut.CloseBitFile;
{ ╬±ΓεßεµΣσφΦσ ∩α∞ ≥Φ}
Registr.Free;
Polinom.Free;
FileIn.Free;
FileOut.Free;
If processExit=true then ShowMessage('╬ß≡αßε≥Ωα ╧≡σ≡Γαφα');
Gauge1.Visible:=false;
Label1.Visible:=true;
Label1.Caption:='╬ß≡αßε≥Ωα ταΓσ≡°σφα';
Gauge1.Progress:=0;
Bitbtn1.Visible:=false;
Bitbtn2.Visible:=true;
end;
end.