unit Unit5;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Mask, ToolEdit, CurrEdit, ExtCtrls, LMDCustomButton,
  LMDButton, RzLabel;

type
  TForm5 = class(TForm)
    Image1: TImage;
    Label1: TLabel;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    LMDButton2: TLMDButton;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    Label43: TLabel;
    Label44: TLabel;
    Label45: TLabel;
    Label46: TLabel;
    Label47: TLabel;
    Label48: TLabel;
    Label49: TLabel;
    Label50: TLabel;
    Label51: TLabel;
    Label52: TLabel;
    Label53: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    RzURLLabel1: TRzURLLabel;
    Label34: TLabel;
    RxCalcEdit1: TRxCalcEdit;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure LMDButton2Click(Sender: TObject);
    procedure RxCalcEdit1Change(Sender: TObject);
    procedure RzURLLabel1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;
Bool128,Bool32,Bool64,Bool16,Bool8,Bool4,Bool2,Bool1,Bool256,Bool512,Bool1024:Integer;
  T1,T2,T3,T4,T5,T6,T7,T8,Val,Value2:Real;
  Boo1024,Boo512,Boo256,Boo128,Boo64,Boo32,Boo16:Integer;
  Num:Integer;
  KodingValue:Integer;

implementation

uses Unit1, Unit6, Unit9;

{$R *.dfm}

procedure Koding1(Value:Real);
begin
Bool32:=-1;
Bool64:=-1;
Bool16:=-1;
Bool256:=-1;
Bool512:=-1;
Bool1024:=-1;
Val:=128;
if Val>Abs(Value) then
begin
Val:=0;
Bool128:=0;
T2:=0;
end
else
begin
Val:=128;
Bool128:=1;
T2:=1;
end;


if Bool128=0 then
begin
Val:=32;
if Val>Abs(Value) then
begin
Val:=0;
Bool32:=0;
T3:=0;
end
else
begin
Bool32:=1;
T3:=1;
end;
end//Конец if Bool128=0//
else
begin
Val:=512;
if Val>Abs(Value) then
begin
Val:=128;
Bool512:=0;
T3:=0;
end
else
begin
Bool512:=1;
T3:=1;
end;
end;

if Bool32<>-1 then
begin

if Bool32=0 then
begin
Val:=16;
if Val>Abs(Value) then
begin
Val:=0;
T4:=0;
end
else
begin
T4:=1;
end;
end//Конец if Bool32=0//
else
begin
Val:=64;
if Val>Abs(Value) then
begin
Val:=32;
Bool16:=0;
T4:=0;
end
else
begin
Val:=64;
T4:=1;
end;
end;

end;

if Bool512<>-1 then
begin

if Bool512=0 then
begin
Val:=256;
if Val>Abs(Value) then
begin
Val:=128;
T4:=0;
end
else
begin
T4:=1;
end;
end//Конец if Bool512=0//
else
begin
Val:=1024;
if Val>Abs(Value) then
begin
Val:=512;
T4:=0;
end
else
begin
Val:=1024;
T4:=1;
end;
end;

end;

end;



Procedure Koding2(Value,Value2:Real);
begin
if Value2=1024 then
begin
Value2:=Value2+512;
if Value2>Abs(Value) then
begin
Value2:=Value2-512;
T5:=0;
end
else
begin
T5:=1;
end;

Value2:=Value2+256;
if Value2>Abs(Value) then
begin
Value2:=Value2-256;
T6:=0;
end
else
begin
T6:=1;
end;

Value2:=Value2+128;
if Value2>Abs(Value) then
begin
Value2:=Value2-128;
T7:=0;
end
else
begin
T7:=1;
end;

Value2:=Value2+64;
if Value2>Abs(Value) then
begin
Value2:=Value2-64;
T8:=0;
end
else
begin
T8:=1;
end;
end;


if Value2=512 then
begin
Value2:=Value2+256;
if Value2>Abs(Value) then
begin
Value2:=Value2-256;
T5:=0;
end
else
begin
T5:=1;
end;

Value2:=Value2+128;
if Value2>Abs(Value) then
begin
Value2:=Value2-128;
T6:=0;
end
else
begin
T6:=1;
end;

Value2:=Value2+64;
if Value2>Abs(Value) then
begin
Value2:=Value2-64;
T7:=0;
end
else
begin
T7:=1;
end;

Value2:=Value2+32;
if Value2>Abs(Value) then
begin
Value2:=Value2-32;
T8:=0;
end
else
begin
T8:=1;
end;
end;



if Value2=256 then
begin
Value2:=Value2+128;
if Value2>Abs(Value) then
begin
Value2:=Value2-128;
T5:=0;
end
else
begin
T5:=1;
end;

Value2:=Value2+64;
if Value2>Abs(Value) then
begin
Value2:=Value2-64;
T6:=0;
end
else
begin
T6:=1;
end;

Value2:=Value2+32;
if Value2>Abs(Value) then
begin
Value2:=Value2-32;
T7:=0;
end
else
begin
T7:=1;
end;

Value2:=Value2+16;
if Value2>Abs(Value) then
begin
Value2:=Value2-16;
T8:=0;
end
else
begin
T8:=1;
end;
end;



if Value2=128 then
begin
Value2:=Value2+64;
if Value2>Abs(Value) then
begin
Value2:=Value2-64;
T5:=0;
end
else
begin
T5:=1;
end;

Value2:=Value2+32;
if Value2>Abs(Value) then
begin
Value2:=Value2-32;
T6:=0;
end
else
begin
T6:=1;
end;

Value2:=Value2+16;
if Value2>Abs(Value) then
begin
Value2:=Value2-16;
T7:=0;
end
else
begin
T7:=1;
end;

Value2:=Value2+8;
if Value2>Abs(Value) then
begin
Value2:=Value2-8;
T8:=0;
end
else
begin
T8:=1;
end;
end;



if Value2=64 then
begin
Value2:=Value2+32;
if Value2>Abs(Value) then
begin
Value2:=Value2-32;
T5:=0;
end
else
begin
T5:=1;
end;

Value2:=Value2+16;
if Value2>Abs(Value) then
begin
Value2:=Value2-16;
T6:=0;
end
else
begin
T6:=1;
end;

Value2:=Value2+8;
if Value2>Abs(Value) then
begin
Value2:=Value2-8;
T7:=0;
end
else
begin
T7:=1;
end;

Value2:=Value2+4;
if Value2>Abs(Value) then
begin
Value2:=Value2-4;
T8:=0;
end
else
begin
T8:=1;
end;
end;



if Value2=32 then
begin
Value2:=Value2+16;
if Value2>Abs(Value) then
begin
Value2:=Value2-16;
T5:=0;
end
else
begin
T5:=1;
end;

Value2:=Value2+8;
if Value2>Abs(Value) then
begin
Value2:=Value2-8;
T6:=0;
end
else
begin
T6:=1;
end;

Value2:=Value2+4;
if Value2>Abs(Value) then
begin
Value2:=Value2-4;
T7:=0;
end
else
begin
T7:=1;
end;

Value2:=Value2+2;
if Value2>Abs(Value) then
begin
Value2:=Value2-2;
T8:=0;
end
else
begin
T8:=1;
end;
end;



if (Value2=16) or (Value2=0) then
begin
Value2:=Value2+8;
if Value2>Abs(Value) then
begin
Value2:=Value2-8;
T5:=0;
end
else
begin
T5:=1;
end;

Value2:=Value2+4;
if Value2>Abs(Value) then
begin
Value2:=Value2-4;
T6:=0;
end
else
begin
T6:=1;
end;

Value2:=Value2+2;
if Value2>Abs(Value) then
begin
Value2:=Value2-2;
T7:=0;
end
else
begin
T7:=1;
end;

Value2:=Value2+1;
if Value2>Abs(Value) then
begin
Value2:=Value2-1;
T8:=0;
end
else
begin
T8:=1;
end;
end;
Val:=Value2

end;



procedure TForm5.Button1Click(Sender: TObject);
begin
//Koding1(Form5.RxCalcEdit1.Value);
//Koding2(Form5.RxCalcEdit1.Value,Val);
end;

procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.Close;
end;

procedure TForm5.LMDButton2Click(Sender: TObject);
begin
Num:=Num+1;
if Num=1 then
begin
Form5.Label1.Caption:='Начало 1-го такта. Определение знака входного сигнала';
if KodingValue>0 then
begin
Form5.Image4.Visible:=false;
Form5.Image5.Visible:=true;
Form5.Label14.Caption:='1';
Form5.Label22.Caption:='0';
Form5.Label23.Visible:=true;
Form5.Label24.Visible:=true;
Form5.Label25.Visible:=true;
Form5.Label26.Visible:=true;
Form5.Label27.Visible:=true;
Form5.Label28.Visible:=true;
Form5.Label29.Visible:=true;
Form5.Label30.Visible:=true;
Form5.Label31.Visible:=true;
Form5.Label32.Visible:=true;
Form5.Label33.Visible:=true;
Form5.Label3.Visible:=false;
Form5.Label4.Visible:=false;
Form5.Label5.Visible:=false;
Form5.Label6.Visible:=false;
Form5.Label7.Visible:=false;
Form5.Label8.Visible:=false;
Form5.Label9.Visible:=false;
Form5.Label10.Visible:=false;
Form5.Label11.Visible:=false;
Form5.Label12.Visible:=false;
Form5.Label13.Visible:=false;
end
else
begin
Form5.Image2.Visible:=false;
Form5.Image3.Visible:=true;
Form5.Label14.Caption:='1';
Form5.Label22.Caption:='1';
Form5.Label3.Visible:=true;
Form5.Label4.Visible:=true;
Form5.Label5.Visible:=true;
Form5.Label6.Visible:=true;
Form5.Label7.Visible:=true;
Form5.Label8.Visible:=true;
Form5.Label9.Visible:=true;
Form5.Label10.Visible:=true;
Form5.Label11.Visible:=true;
Form5.Label12.Visible:=true;
Form5.Label13.Visible:=true;
Form5.Label23.Visible:=false;
Form5.Label24.Visible:=false;
Form5.Label25.Visible:=false;
Form5.Label26.Visible:=false;
Form5.Label27.Visible:=false;
Form5.Label28.Visible:=false;
Form5.Label29.Visible:=false;
Form5.Label30.Visible:=false;
Form5.Label31.Visible:=false;
Form5.Label32.Visible:=false;
Form5.Label33.Visible:=false;
end;
Form5.Label22.Visible:=true;
end;

if Num=2 then
begin

Form5.Label1.Caption:='Конец 1-го такта. Определение знака входного сигнала';
if KodingValue>0 then
begin
Form5.Image4.Visible:=false;
Form5.Image5.Visible:=true;
Form5.Label14.Caption:='1';
end
else
begin
Form5.Image2.Visible:=false;
Form5.Image3.Visible:=true;
Form5.Label14.Caption:='0';
end;
Form5.Label22.Visible:=false;
Form5.Label15.Caption:='0';
end;


if Num=3 then
begin
Bool32:=-1;
Bool64:=-1;
Bool16:=-1;
Bool256:=-1;
Bool512:=-1;
Bool1024:=-1;
Val:=128;
if Val>Abs(KodingValue) then
begin
Val:=0;
Bool128:=0;
T2:=0;
end
else
begin
Val:=128;
Bool128:=1;
T2:=1;
end;
Form5.Label1.Caption:='Начало 2-го такта. Определение номера сегмента амплитудной характеристики';
if Bool128=0 then
Form5.Label22.Caption:='1'
else
Form5.Label22.Caption:='0';
Form5.Label22.Visible:=true;
Form5.Label15.Caption:='1';
if KodingValue>0 then
Form5.Label26.Caption:='1'
else
Form5.Label6.Caption:='1';
Form5.Label46.Caption:='1';
if KodingValue>0 then
Label2.Caption:='128'
else
Label2.Caption:='-128';
end;

if Num=4 then
begin
Form5.Label1.Caption:='Конец 2-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=false;
if Bool128=0 then
begin
Label2.Caption:='0';
Form5.Label15.Caption:='0';
Form5.Label46.Caption:='0';
if KodingValue>0 then
Form5.Label26.Caption:='0'
else
Form5.Label6.Caption:='0';
end
else
begin
Form5.Label15.Caption:='1';
Form5.Label46.Caption:='1';

if KodingValue>0 then
Label2.Caption:='128'
else
Label2.Caption:='-128';
if KodingValue>0 then
Form5.Label26.Caption:='1'
else
Form5.Label6.Caption:='1';
end;
end;



if Num=5 then
begin

if Bool128=0 then
begin
Val:=32;
if Val>Abs(KodingValue) then
begin
Val:=0;
Bool32:=0;
T3:=0;
end
else
begin
Bool32:=1;
T3:=1;
end;
end//Конец if Bool128=0//
else
begin
Val:=512;
if Val>Abs(KodingValue) then
begin
Val:=128;
Bool512:=0;
T3:=0;
end
else
begin
Bool512:=1;
T3:=1;
end;
end;

Form5.Label1.Caption:='Начало 3-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=true;
Form5.Label16.Caption:='1';

Form5.Label6.Caption:='0';
Form5.Label26.Caption:='0';
Form5.Label46.Caption:='0';


if Bool32=0 then
begin
Form5.Label22.Caption:='1';
if KodingValue>0 then
Form5.Label28.Caption:='1'
else
Form5.Label8.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Label2.Caption:='32'
else
Label2.Caption:='-32';
end;

if Bool32=1 then
begin
Form5.Label22.Caption:='0';
if KodingValue>0 then
Form5.Label28.Caption:='1'
else
Form5.Label8.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Label2.Caption:='32'
else
Label2.Caption:='-32';
end;


if Bool512=0 then
begin
Form5.Label22.Caption:='1';
if KodingValue>0 then
Form5.Label24.Caption:='1'
else
Form5.Label4.Caption:='1';
Form5.Label44.Caption:='1';
if KodingValue>0 then
Label2.Caption:='512'
else
Label2.Caption:='-512';
end;

if Bool512=1 then
begin
Form5.Label22.Caption:='0';
if KodingValue>0 then
Form5.Label24.Caption:='1'
else
Form5.Label4.Caption:='1';
Form5.Label44.Caption:='1';
if KodingValue>0 then
Label2.Caption:='512'
else
Label2.Caption:='-512';
end;
end;


if Num=6 then
begin
Form5.Label1.Caption:='Конец 3-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=false;

if Bool32=0 then
begin
Form5.Label16.Caption:='0';
if KodingValue>0 then
Form5.Label28.Caption:='0'
else
Form5.Label8.Caption:='0';
Form5.Label48.Caption:='0';
Label2.Caption:='0';
end;

if Bool32=1 then
begin
Form5.Label16.Caption:='1';
if KodingValue>0 then
Form5.Label28.Caption:='1'
else
Form5.Label8.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Label2.Caption:='32'
else
Label2.Caption:='-32';
end;


if Bool512=0 then
begin
Form5.Label16.Caption:='0';
Form5.Label6.Caption:='1';
Form5.Label26.Caption:='1';
Form5.Label46.Caption:='1';
if KodingValue>0 then
Form5.Label24.Caption:='0'
else
Form5.Label4.Caption:='0';
Form5.Label44.Caption:='0';
if KodingValue>0 then
Label2.Caption:='128'
else
Label2.Caption:='-128';
end;

if Bool512=1 then
begin
Form5.Label16.Caption:='1';
if KodingValue>0 then
Form5.Label24.Caption:='1'
else
Form5.Label4.Caption:='1';
Form5.Label44.Caption:='1';
if KodingValue>0 then
Label2.Caption:='512'
else
Label2.Caption:='-512';
end;
end;



if Num=7 then
begin

if Bool32<>-1 then
begin

if Bool32=0 then
begin
Val:=16;
if Val>Abs(KodingValue) then
begin
Val:=0;
T4:=0;
end
else
begin
T4:=1;
end;
end//Конец if Bool32=0//
else
begin
Val:=64;
if Val>Abs(KodingValue) then
begin
Val:=32;
Bool16:=0;
T4:=0;
end
else
begin
Val:=64;
T4:=1;
end;
end;

end;

if Bool512<>-1 then
begin

if Bool512=0 then
begin
Val:=256;
if Val>Abs(KodingValue) then
begin
Val:=128;
T4:=0;
end
else
begin
T4:=1;
end;
end//Конец if Bool512=0//
else
begin
Val:=1024;
if Val>Abs(KodingValue) then
begin
Val:=512;
T4:=0;
end
else
begin
Val:=1024;
T4:=1;
end;
end;

end;

Form5.Label1.Caption:='Начало 4-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=true;
Form5.Label17.Caption:='1';


Form5.Label8.Caption:='0';
Form5.Label28.Caption:='0';
Form5.Label48.Caption:='0';
Form5.Label4.Caption:='0';
Form5.Label24.Caption:='0';
Form5.Label44.Caption:='0';
Form5.Label6.Caption:='0';
Form5.Label26.Caption:='0';
Form5.Label46.Caption:='0';


if Val=0 then
begin
Form5.Label22.Caption:='1';
if KodingValue>0 then
Form5.Label29.Caption:='1'
else
Form5.Label9.Caption:='1';
Form5.Label49.Caption:='1';
if KodingValue>0 then
Label2.Caption:='16'
else
Label2.Caption:='-16';
end;

if Val=16 then
begin
Form5.Label22.Caption:='0';
if KodingValue>0 then
Form5.Label29.Caption:='1'
else
Form5.Label9.Caption:='1';
Form5.Label49.Caption:='1';
if KodingValue>0 then
Label2.Caption:='16'
else
Label2.Caption:='-16';
end;


if Val=32 then
begin
Form5.Label22.Caption:='1';
if KodingValue>0 then
Form5.Label27.Caption:='1'
else
Form5.Label7.Caption:='1';
Form5.Label47.Caption:='1';
if KodingValue>0 then
Label2.Caption:='64'
else
Label2.Caption:='-64';
end;

if Val=64 then
begin
Form5.Label22.Caption:='0';
if KodingValue>0 then
Form5.Label27.Caption:='1'
else
Form5.Label7.Caption:='1';
Form5.Label47.Caption:='1';
if KodingValue>0 then
Label2.Caption:='64'
else
Label2.Caption:='-64';
end;


if Val=128 then
begin
Form5.Label22.Caption:='1';
if KodingValue>0 then
Form5.Label25.Caption:='1'
else
Form5.Label5.Caption:='1';
Form5.Label45.Caption:='1';
if KodingValue>0 then
Label2.Caption:='256'
else
Label2.Caption:='-256';
end;

if Val=256 then
begin
Form5.Label22.Caption:='0';
if KodingValue>0 then
Form5.Label25.Caption:='1'
else
Form5.Label5.Caption:='1';
Form5.Label45.Caption:='1';
if KodingValue>0 then
Label2.Caption:='256'
else
Label2.Caption:='-256';
end;


if Val=512 then
begin
Form5.Label22.Caption:='1';
if KodingValue>0 then
Form5.Label23.Caption:='1'
else
Form5.Label3.Caption:='1';
Form5.Label43.Caption:='1';
if KodingValue>0 then
Label2.Caption:='1024'
else
Label2.Caption:='-1024';
end;

if Val=1024 then
begin
Form5.Label22.Caption:='0';
if KodingValue>0 then
Form5.Label23.Caption:='1'
else
Form5.Label3.Caption:='1';
Form5.Label43.Caption:='1';
if KodingValue>0 then
Label2.Caption:='1024'
else
Label2.Caption:='-1024';
end;
end;


if Num=8 then
begin
Form5.Label1.Caption:='Конец 4-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=false;


if Val=0 then
begin
Form5.Label17.Caption:='0';
if KodingValue>0 then
Form5.Label29.Caption:='0'
else
Form5.Label9.Caption:='0';
Form5.Label49.Caption:='0';
Label2.Caption:='0';
end;

if Val=16 then
begin
Form5.Label17.Caption:='1';
if KodingValue>0 then
Form5.Label29.Caption:='1'
else
Form5.Label9.Caption:='1';
Form5.Label49.Caption:='1';
if KodingValue>0 then
Label2.Caption:='16'
else
Label2.Caption:='-16';
end;


if Val=32 then
begin
Form5.Label17.Caption:='0';
Form5.Label8.Caption:='1';
Form5.Label28.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Form5.Label27.Caption:='0'
else
Form5.Label7.Caption:='0';
Form5.Label47.Caption:='0';
if KodingValue>0 then
Label2.Caption:='32'
else
Label2.Caption:='-32';
end;

if Val=64 then
begin
Form5.Label17.Caption:='1';
if KodingValue>0 then
Form5.Label27.Caption:='1'
else
Form5.Label7.Caption:='1';
Form5.Label47.Caption:='1';
if KodingValue>0 then
Label2.Caption:='64'
else
Label2.Caption:='-64';
end;


if Val=128 then
begin
Form5.Label17.Caption:='0';
Form5.Label6.Caption:='1';
Form5.Label26.Caption:='1';
Form5.Label46.Caption:='1';
if KodingValue>0 then
Form5.Label25.Caption:='0'
else
Form5.Label5.Caption:='0';
Form5.Label45.Caption:='0';
if KodingValue>0 then
Label2.Caption:='128'
else
Label2.Caption:='-128';
end;

if Val=256 then
begin
Form5.Label17.Caption:='1';
if KodingValue>0 then
Form5.Label25.Caption:='1'
else
Form5.Label5.Caption:='1';
Form5.Label45.Caption:='1';
if KodingValue>0 then
Label2.Caption:='256'
else
Label2.Caption:='-256';
end;


if Val=512 then
begin
Form5.Label17.Caption:='0';
Form5.Label4.Caption:='1';
Form5.Label24.Caption:='1';
Form5.Label44.Caption:='1';
if KodingValue>0 then
Form5.Label23.Caption:='0'
else
Form5.Label3.Caption:='0';
Form5.Label43.Caption:='0';
if KodingValue>0 then
Label2.Caption:='512'
else
Label2.Caption:='-512';
end;

if Val=1024 then
begin
Form5.Label17.Caption:='1';
if KodingValue>0 then
Form5.Label23.Caption:='1'
else
Form5.Label3.Caption:='1';
Form5.Label43.Caption:='1';
if KodingValue>0 then
Label2.Caption:='1024'
else
Label2.Caption:='-1024';
end;
end;



if Num=9 then
begin
Form5.Label1.Caption:='Начало 5-го такта. Определение шага внутри сегмента';
Form5.Label22.Visible:=true;
Form5.Label18.Caption:='1';

if Val=1024 then
begin
Val:=Val+512;
Value2:=Val;
Boo1024:=1;
if Val>Abs(KodingValue) then
begin
Val:=Val-512;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label24.Caption:='1'
else
Form5.Label4.Caption:='1';
Form5.Label44.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Val=512 then
begin
Val:=Val+256;
Value2:=Val;
Boo512:=1;
if Val>Abs(KodingValue) then
begin
Val:=Val-256;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label25.Caption:='1'
else
Form5.Label5.Caption:='1';
Form5.Label45.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Val=256 then
begin
Val:=Val+128;
Value2:=Val;
Boo256:=1;
if Val>Abs(KodingValue) then
begin
Val:=Val-128;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label26.Caption:='1'
else
Form5.Label6.Caption:='1';
Form5.Label46.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Val=128 then
begin
Val:=Val+64;
Value2:=Val;
Boo128:=1;
if Val>Abs(KodingValue) then
begin
Val:=Val-64;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label27.Caption:='1'
else
Form5.Label7.Caption:='1';
Form5.Label47.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Val=64 then
begin
Val:=Val+32;
Value2:=Val;
Boo64:=1;
if Val>Abs(KodingValue) then
begin
Val:=Val-32;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label28.Caption:='1'
else
Form5.Label8.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Val=32 then
begin
Val:=Val+16;
Value2:=Val;
Boo32:=1;
if Val>Abs(KodingValue) then
begin
Val:=Val-16;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label29.Caption:='1'
else
Form5.Label9.Caption:='1';
Form5.Label49.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if (Val=16) or (Val=0) then
begin
Val:=Val+8;
Value2:=Val;
Boo16:=1;
if Val>Abs(KodingValue) then
begin
Val:=Val-8;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label30.Caption:='1'
else
Form5.Label10.Caption:='1';
Form5.Label50.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;
end;




if Num=10 then
begin
Form5.Label1.Caption:='Конец 5-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=false;



if Boo1024=1 then
begin
if Val=Value2 then
begin
Form5.Label18.Caption:='1';
end
else
begin
T5:=1;
Form5.Label18.Caption:='0';
if KodingValue>0 then
Form5.Label24.Caption:='0'
else
Form5.Label4.Caption:='0';
Form5.Label44.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;



if Boo512=1 then
begin
if Val=Value2 then
begin
Form5.Label18.Caption:='1';
end
else
begin
T5:=1;
Form5.Label18.Caption:='0';
if KodingValue>0 then
Form5.Label25.Caption:='0'
else
Form5.Label5.Caption:='0';
Form5.Label45.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo256=1 then
begin
if Val=Value2 then
begin
Form5.Label18.Caption:='1';
end
else
begin
T5:=1;
Form5.Label18.Caption:='0';
if KodingValue>0 then
Form5.Label26.Caption:='0'
else
Form5.Label6.Caption:='0';
Form5.Label46.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;



if Boo128=1 then
begin
if Val=Value2 then
begin
Form5.Label18.Caption:='1';
end
else
begin
T5:=1;
Form5.Label18.Caption:='0';
if KodingValue>0 then
Form5.Label27.Caption:='0'
else
Form5.Label7.Caption:='0';
Form5.Label47.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo64=1 then
begin
if Val=Value2 then
begin
Form5.Label18.Caption:='1';
end
else
begin
T5:=1;
Form5.Label18.Caption:='0';
if KodingValue>0 then
Form5.Label28.Caption:='0'
else
Form5.Label8.Caption:='0';
Form5.Label48.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo32=1 then
begin
if Val=Value2 then
begin
Form5.Label18.Caption:='1';
end
else
begin
T5:=1;
Form5.Label18.Caption:='0';
if KodingValue>0 then
Form5.Label29.Caption:='0'
else
Form5.Label9.Caption:='0';
Form5.Label49.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo16=1 then
begin
if Val=Value2 then
begin
Form5.Label18.Caption:='1';
end
else
begin
T5:=1;
Form5.Label18.Caption:='0';
if KodingValue>0 then
Form5.Label30.Caption:='0'
else
Form5.Label10.Caption:='0';
Form5.Label50.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;

end;



if Num=11 then
begin
Form5.Label1.Caption:='Начало 6-го такта. Определение шага внутри сегмента';
Form5.Label22.Visible:=true;
Form5.Label19.Caption:='1';

if Boo1024=1 then
begin
Val:=Val+256;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-256;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label25.Caption:='1'
else
Form5.Label5.Caption:='1';
Form5.Label45.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo512=1 then
begin
Val:=Val+128;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-128;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label26.Caption:='1'
else
Form5.Label6.Caption:='1';
Form5.Label46.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo256=1 then
begin
Val:=Val+64;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-64;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label27.Caption:='1'
else
Form5.Label7.Caption:='1';
Form5.Label47.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo128=1 then
begin
Val:=Val+32;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-32;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label28.Caption:='1'
else
Form5.Label8.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Boo64=1 then
begin
Val:=Val+16;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-16;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label29.Caption:='1'
else
Form5.Label9.Caption:='1';
Form5.Label49.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo32=1 then
begin
Val:=Val+8;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-8;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label30.Caption:='1'
else
Form5.Label10.Caption:='1';
Form5.Label50.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Boo16=1 then
begin
Val:=Val+4;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-4;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label31.Caption:='1'
else
Form5.Label11.Caption:='1';
Form5.Label51.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;
end;




if Num=12 then
begin
Form5.Label1.Caption:='Конец 6-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=false;



if Boo1024=1 then
begin
if Val=Value2 then
begin
Form5.Label19.Caption:='1';
end
else
begin
T5:=1;
Form5.Label19.Caption:='0';
if KodingValue>0 then
Form5.Label25.Caption:='0'
else
Form5.Label5.Caption:='0';
Form5.Label45.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo512=1 then
begin
if Val=Value2 then
begin
Form5.Label19.Caption:='1';
end
else
begin
T5:=1;
Form5.Label19.Caption:='0';
if KodingValue>0 then
Form5.Label26.Caption:='0'
else
Form5.Label6.Caption:='0';
Form5.Label46.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;

if Boo256=1 then
begin
if Val=Value2 then
begin
Form5.Label19.Caption:='1';
end
else
begin
T5:=1;
Form5.Label19.Caption:='0';
if KodingValue>0 then
Form5.Label27.Caption:='0'
else
Form5.Label7.Caption:='0';
Form5.Label47.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo128=1 then
begin
if Val=Value2 then
begin
Form5.Label19.Caption:='1';
end
else
begin
T5:=1;
Form5.Label19.Caption:='0';
if KodingValue>0 then
Form5.Label28.Caption:='0'
else
Form5.Label8.Caption:='0';
Form5.Label48.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo64=1 then
begin
if Val=Value2 then
begin
Form5.Label19.Caption:='1';
end
else
begin
T5:=1;
Form5.Label19.Caption:='0';
if KodingValue>0 then
Form5.Label29.Caption:='0'
else
Form5.Label9.Caption:='0';
Form5.Label49.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo32=1 then
begin
if Val=Value2 then
begin
Form5.Label19.Caption:='1';
end
else
begin
T5:=1;
Form5.Label19.Caption:='0';
if KodingValue>0 then
Form5.Label30.Caption:='0'
else
Form5.Label10.Caption:='0';
Form5.Label50.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo16=1 then
begin
if Val=Value2 then
begin
Form5.Label19.Caption:='1';
end
else
begin
T5:=1;
Form5.Label19.Caption:='0';
if KodingValue>0 then
Form5.Label31.Caption:='0'
else
Form5.Label11.Caption:='0';
Form5.Label51.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;
end;




if Num=13 then
begin
Form5.Label1.Caption:='Начало 7-го такта. Определение шага внутри сегмента';
Form5.Label22.Visible:=true;
Form5.Label20.Caption:='1';

if Boo1024=1 then
begin
Val:=Val+128;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-128;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label26.Caption:='1'
else
Form5.Label6.Caption:='1';
Form5.Label46.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo512=1 then
begin
Val:=Val+64;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-64;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label27.Caption:='1'
else
Form5.Label7.Caption:='1';
Form5.Label47.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo256=1 then
begin
Val:=Val+32;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-32;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label28.Caption:='1'
else
Form5.Label8.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo128=1 then
begin
Val:=Val+16;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-16;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label29.Caption:='1'
else
Form5.Label9.Caption:='1';
Form5.Label49.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Boo64=1 then
begin
Val:=Val+8;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-8;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label30.Caption:='1'
else
Form5.Label10.Caption:='1';
Form5.Label50.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo32=1 then
begin
Val:=Val+4;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-4;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label31.Caption:='1'
else
Form5.Label11.Caption:='1';
Form5.Label51.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Boo16=1 then
begin
Val:=Val+2;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-2;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label32.Caption:='1'
else
Form5.Label12.Caption:='1';
Form5.Label52.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;
end;





if Num=14 then
begin
Form5.Label1.Caption:='Конец 7-го такта. Определение номера сегмента амплитудной характеристики';
Form5.Label22.Visible:=false;



if Boo1024=1 then
begin
if Val=Value2 then
begin
Form5.Label20.Caption:='1';
end
else
begin
T5:=1;
Form5.Label20.Caption:='0';
if KodingValue>0 then
Form5.Label26.Caption:='0'
else
Form5.Label6.Caption:='0';
Form5.Label46.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo512=1 then
begin
if Val=Value2 then
begin
Form5.Label20.Caption:='1';
end
else
begin
T5:=1;
Form5.Label20.Caption:='0';
if KodingValue>0 then
Form5.Label27.Caption:='0'
else
Form5.Label7.Caption:='0';
Form5.Label47.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;

if Boo256=1 then
begin
if Val=Value2 then
begin
Form5.Label20.Caption:='1';
end
else
begin
T5:=1;
Form5.Label20.Caption:='0';
if KodingValue>0 then
Form5.Label28.Caption:='0'
else
Form5.Label8.Caption:='0';
Form5.Label48.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo128=1 then
begin
if Val=Value2 then
begin
Form5.Label20.Caption:='1';
end
else
begin
T5:=1;
Form5.Label20.Caption:='0';
if KodingValue>0 then
Form5.Label29.Caption:='0'
else
Form5.Label9.Caption:='0';
Form5.Label49.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo64=1 then
begin
if Val=Value2 then
begin
Form5.Label20.Caption:='1';
end
else
begin
T5:=1;
Form5.Label20.Caption:='0';
if KodingValue>0 then
Form5.Label30.Caption:='0'
else
Form5.Label10.Caption:='0';
Form5.Label50.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo32=1 then
begin
if Val=Value2 then
begin
Form5.Label20.Caption:='1';
end
else
begin
T5:=1;
Form5.Label20.Caption:='0';
if KodingValue>0 then
Form5.Label31.Caption:='0'
else
Form5.Label11.Caption:='0';
Form5.Label51.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo16=1 then
begin
if Val=Value2 then
begin
Form5.Label20.Caption:='1';
end
else
begin
T5:=1;
Form5.Label20.Caption:='0';
if KodingValue>0 then
Form5.Label32.Caption:='0'
else
Form5.Label12.Caption:='0';
Form5.Label52.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;
end;




if Num=15 then
begin
Form5.Label1.Caption:='Начало 8-го такта. Определение шага внутри сегмента';
Form5.Label22.Visible:=true;
Form5.Label21.Caption:='1';

if Boo1024=1 then
begin
Val:=Val+64;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-64;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label27.Caption:='1'
else
Form5.Label7.Caption:='1';
Form5.Label47.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo512=1 then
begin
Val:=Val+32;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-32;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label28.Caption:='1'
else
Form5.Label8.Caption:='1';
Form5.Label48.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo256=1 then
begin
Val:=Val+16;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-16;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label29.Caption:='1'
else
Form5.Label9.Caption:='1';
Form5.Label49.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo128=1 then
begin
Val:=Val+8;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-8;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label30.Caption:='1'
else
Form5.Label10.Caption:='1';
Form5.Label50.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Boo64=1 then
begin
Val:=Val+4;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-4;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label31.Caption:='1'
else
Form5.Label11.Caption:='1';
Form5.Label51.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;


if Boo32=1 then
begin
Val:=Val+2;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-2;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label32.Caption:='1'
else
Form5.Label12.Caption:='1';
Form5.Label52.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;



if Boo16=1 then
begin
Val:=Val+1;
Value2:=Val;
if Val>Abs(KodingValue) then
begin
Val:=Val-1;
T5:=0;
Form5.Label22.Caption:='1';
end
else
begin
T5:=1;
Form5.Label22.Caption:='0';
end;

if KodingValue>0 then
Form5.Label33.Caption:='1'
else
Form5.Label13.Caption:='1';
Form5.Label53.Caption:='1';
if KodingValue>0 then
Label2.Caption:=FloatToStr(Value2)
else
Label2.Caption:=FloatToStr(-Value2);
end;
end;




if Num=16 then
begin
Form5.Label1.Caption:='Конец 8-го такта. Кодирование завершено.';
Form5.Label22.Visible:=false;



if Boo1024=1 then
begin
if Val=Value2 then
begin
Form5.Label21.Caption:='1';
end
else
begin
T5:=1;
Form5.Label21.Caption:='0';
if KodingValue>0 then
Form5.Label27.Caption:='0'
else
Form5.Label7.Caption:='0';
Form5.Label47.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo512=1 then
begin
if Val=Value2 then
begin
Form5.Label21.Caption:='1';
end
else
begin
T5:=1;
Form5.Label21.Caption:='0';
if KodingValue>0 then
Form5.Label28.Caption:='0'
else
Form5.Label8.Caption:='0';
Form5.Label48.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;

if Boo256=1 then
begin
if Val=Value2 then
begin
Form5.Label21.Caption:='1';
end
else
begin
T5:=1;
Form5.Label21.Caption:='0';
if KodingValue>0 then
Form5.Label29.Caption:='0'
else
Form5.Label9.Caption:='0';
Form5.Label49.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo128=1 then
begin
if Val=Value2 then
begin
Form5.Label21.Caption:='1';
end
else
begin
T5:=1;
Form5.Label21.Caption:='0';
if KodingValue>0 then
Form5.Label30.Caption:='0'
else
Form5.Label10.Caption:='0';
Form5.Label50.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo64=1 then
begin
if Val=Value2 then
begin
Form5.Label21.Caption:='1';
end
else
begin
T5:=1;
Form5.Label21.Caption:='0';
if KodingValue>0 then
Form5.Label31.Caption:='0'
else
Form5.Label11.Caption:='0';
Form5.Label51.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo32=1 then
begin
if Val=Value2 then
begin
Form5.Label21.Caption:='1';
end
else
begin
T5:=1;
Form5.Label21.Caption:='0';
if KodingValue>0 then
Form5.Label32.Caption:='0'
else
Form5.Label12.Caption:='0';
Form5.Label52.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;


if Boo16=1 then
begin
if Val=Value2 then
begin
Form5.Label21.Caption:='1';
end
else
begin
T5:=1;
Form5.Label21.Caption:='0';
if KodingValue>0 then
Form5.Label33.Caption:='0'
else
Form5.Label13.Caption:='0';
Form5.Label53.Caption:='0';
end;
if KodingValue>0 then
Label2.Caption:=FloatToStr(Val)
else
Label2.Caption:=FloatToStr(-Val);
end;
end;


if Num=17 then
begin
randomize;
KodingValue:=Random(4001)-2000;
if KodingValue=0 then
begin
randomize;
KodingValue:=Random(4001)-2000;
end;
Form5.Label1.Caption:='Значение Uаим для кодирования = '+IntToStr(KodingValue)+'.';
Form5.Label34.Caption:=IntToStr(KodingValue);

//Form5.LMDButton2.Enabled:=false;
Num:=0;
//Form5.Label1.Caption:='Введите значение Uаим';
Form5.Label2.Caption:='0';
//Form5.RxCalcEdit1.Value:=0;
Form5.Label3.Caption:='0';
Form5.Label4.Caption:='0';
Form5.Label5.Caption:='0';
Form5.Label6.Caption:='0';
Form5.Label7.Caption:='0';
Form5.Label8.Caption:='0';
Form5.Label9.Caption:='0';
Form5.Label10.Caption:='0';
Form5.Label11.Caption:='0';
Form5.Label12.Caption:='0';
Form5.Label13.Caption:='0';
Form5.Label23.Caption:='0';
Form5.Label24.Caption:='0';
Form5.Label25.Caption:='0';
Form5.Label26.Caption:='0';
Form5.Label27.Caption:='0';
Form5.Label28.Caption:='0';
Form5.Label29.Caption:='0';
Form5.Label30.Caption:='0';
Form5.Label31.Caption:='0';
Form5.Label32.Caption:='0';
Form5.Label33.Caption:='0';
Form5.Label43.Caption:='0';
Form5.Label44.Caption:='0';
Form5.Label45.Caption:='0';
Form5.Label46.Caption:='0';
Form5.Label47.Caption:='0';
Form5.Label48.Caption:='0';
Form5.Label49.Caption:='0';
Form5.Label50.Caption:='0';
Form5.Label51.Caption:='0';
Form5.Label52.Caption:='0';
Form5.Label53.Caption:='0';
Form5.Label14.Caption:='0';
Form5.Label15.Caption:='0';
Form5.Label16.Caption:='0';
Form5.Label17.Caption:='0';
Form5.Label18.Caption:='0';
Form5.Label19.Caption:='0';
Form5.Label20.Caption:='0';
Form5.Label21.Caption:='0';
Form5.Image3.Visible:=false;
Form5.Image5.Visible:=false;
Form5.Image2.Visible:=true;
Form5.Image4.Visible:=true;
Form5.Label3.Visible:=true;
Form5.Label4.Visible:=true;
Form5.Label5.Visible:=true;
Form5.Label6.Visible:=true;
Form5.Label7.Visible:=true;
Form5.Label8.Visible:=true;
Form5.Label9.Visible:=true;
Form5.Label10.Visible:=true;
Form5.Label11.Visible:=true;
Form5.Label12.Visible:=true;
Form5.Label13.Visible:=true;
Form5.Label23.Visible:=true;
Form5.LMDButton2.Enabled:=true;
end;




end;

procedure TForm5.RxCalcEdit1Change(Sender: TObject);
begin
{if Form5.RxCalcEdit1.Value=0 then
Form5.LMDButton2.Enabled:=false
else
Form5.LMDButton2.Enabled:=true;}
end;

procedure TForm5.RzURLLabel1Click(Sender: TObject);
begin
Form5.Hide;
Form9.Show;
end;

procedure TForm5.FormShow(Sender: TObject);
begin
randomize;
KodingValue:=Random(4001)-2000;
if KodingValue=0 then
begin
randomize;
KodingValue:=Random(4001)-2000;
end;
Form5.Label1.Caption:='Значение Uаим для кодирования = '+IntToStr(KodingValue)+'.';
Form5.Label34.Caption:=IntToStr(KodingValue);
end;

end.
