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   
Pascal/Delphi Source File  |  2001-06-26  |  3KB  |  129 lines

  1.      {*─αφφ√Θ ∞εΣ≤δⁿ Γ√∩εδφ σ≥ ε±φεΓφ≤■ ⌠≤φΩ÷Φ■ - ±Ω≡σ∞ßδΦ≡εΓαφΦσ*}
  2. unit Unit3;
  3.  
  4. interface
  5.  
  6. uses
  7.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  8.   StdCtrls, Gauges,strbit32, Buttons;
  9.  
  10. procedure Peredach( N1FileIn, N1FileOut,NU1,Polin1,Period1:String);
  11.  
  12.  
  13.  
  14. type
  15.   TForm3 = class(TForm)
  16.     Gauge1: TGauge;
  17.     BitBtn1: TBitBtn;
  18.     BitBtn2: TBitBtn;
  19.     Label1: TLabel;
  20.     procedure BitBtn1Click(Sender: TObject);
  21.     procedure BitBtn2Click(Sender: TObject);
  22.   
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. var
  30.   Form3: TForm3;
  31.   ProcessExit:Boolean;
  32.   NFileIn, NFileOut,NU,Polin,Period:String;
  33. implementation
  34.  
  35. uses Unit1;
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure Peredach( N1FileIn,N1FileOut,NU1,Polin1,Period1:String);
  40.  begin
  41.    NFileIn :=N1FileIn;
  42.    NFileOut:=N1FileOut;
  43.    NU :=NU1;
  44.    Polin :=Polin1;
  45.    Period:=Period1;
  46.  end;
  47.  
  48.  // ╧≡ε÷σΣ≤≡α ε±≥αφεΓΩΦ ∩≡ε÷σ±±α
  49. procedure TForm3.BitBtn1Click(Sender: TObject);
  50. begin
  51.  ProcessExit:=true;
  52.  Close;
  53. end;
  54.  
  55.  // ╧≡ε÷σΣ≤≡α ±Ω≡σ∞ßδΦ≡εΓαφΦ 
  56. procedure TForm3.BitBtn2Click(Sender: TObject);
  57. Var  Registr,Polinom : TStr_Bit;
  58.      FileIn, FileOut : TBitFile;
  59.      Bit,stbit,POS : byte;
  60.      j,i,raz: LongWord;
  61.          pr:int64;
  62. begin
  63.   Label1.Visible:=False;
  64.   Gauge1.Visible:=true;
  65.   Bitbtn2.Visible:=false;
  66.   Bitbtn1.Visible:=true;
  67.    { ┬√ΣσδσφΦσ ∩α∞ ≥Φ }
  68.   Registr := TStr_Bit.Create;
  69.   Polinom := TStr_Bit.Create;
  70.   FileIn := TBitFile.Create;
  71.   FileOut := TBitFile.Create;
  72.   ProcessExit:=False;
  73.   pr:=strtoint(Period);
  74.  Try
  75.     { O≥Ω≡√≥Φσ ⌠αΘδεΓ}
  76.    FileIn.OpenBitFile(NFileIn,btOpenRead,bt8);
  77.    FileOut.OpenBitFile(NFileOut,btCreate, bt8);
  78.    { ╙±≥αφεΓΩα φα≈αδⁿφεπε ±ε±≥ε φΦ  ≡σπΦ±≥≡α ±Ω≡σ∞ßδσ≡α }
  79.    Registr.Init_Sim(NU);
  80.    { ╧≡σεß≡ατεΓαφΦσ ∩εδΦφε∞α Φτ ±Φ∞Γεδⁿφεπε ΓΦΣα Γ ßΦ≥εΓ≤■ ∩σ≡σ∞σφφ≤■}
  81.    Polinom.Init_Sim(Polin);
  82.    raz:=FileIn.SizeOfFile; {╬∩≡σΣσδσφΦσ ≡ατ∞σ≡α ⌠αΦδα}
  83.    J:=0;I:=0;
  84.    Bit := FileIn.ReadBit;  {╫≥σφΦσ ßΦ≥α}
  85.     // ÷ΦΩδ ±Ω≡σ∞ßδΦ≡εΓαφΦ 
  86.  while bit<2 do
  87.      begin
  88.  
  89.        Application.ProcessMessages;  {╬ß≡α∙σφΦσ Ω ∩≡ε÷σΣ≤≡σ Γε Γ≡σ∞  ÷ΦΩδα,
  90.                                    ∩≡σ≡√ΓαφΦσ. ╬±≥αφεΓΩα ∩≡ε÷σ±±α }
  91.        if ProcessExit then Break;     { ╬±≥αφεΓΩα ∩≡ε÷σ±±α }
  92.        stbit:=Registr.ModReg(Polinom); {╤≤∞∞Φ≡εΓαφΦσ ∩ε ε≥ΓεΣα∞ ≡σπΦ±≥≡α}
  93.        POS:=(stbit+Bit) mod 2;
  94.        FileOut.WriteBit(POS);  {╟α∩Φ±ⁿ ßΦ≥α}
  95.        Registr.BitDisplase(stbit);{╤ΣΓΦπ Φ τα∩Φ±ⁿ φ≤δσΓεπε ßΦ≥α Γ ≡σπΦ±≥≡}
  96.        Bit := Filein.ReadBit;  {╫≥σφΦσ ±δσΣ≤■∙σπε ßΦ≥α}
  97.        inc(j);
  98.        inc(i);
  99.       if i=pr then
  100.       begin
  101.        Registr.Init_Sim(NU);
  102.        i:=0;
  103.       end;
  104.       Gauge1.Progress:=100*j div raz;
  105.      end;
  106.  Except   on EfileBitError do {╬°ΦßΩα εß≡αßε≥ΩΦ ⌠αΘδα}
  107.      ShowMessage('╬°ΦßΩα εß≡αßε≥ΩΦ');
  108.  end;
  109.   { ╟αΩ≡√≥Φσ εß≡αßα≥√Γασ∞√⌡ ⌠αΘδεΓ}
  110.    FileIn.CloseBitFile;
  111.    FileOut.CloseBitFile;
  112.    { ╬±ΓεßεµΣσφΦσ ∩α∞ ≥Φ}
  113.   Registr.Free;
  114.   Polinom.Free;
  115.   FileIn.Free;
  116.   FileOut.Free;
  117.   If processExit=true then ShowMessage('╬ß≡αßε≥Ωα ╧≡σ≡Γαφα');
  118.   Gauge1.Visible:=false;
  119.   Label1.Visible:=true;
  120.   Label1.Caption:='╬ß≡αßε≥Ωα ταΓσ≡°σφα';
  121.   Gauge1.Progress:=0;
  122.   Bitbtn1.Visible:=false;
  123.   Bitbtn2.Visible:=true;
  124. end;
  125.  
  126.  
  127. end.
  128.  
  129.