unit uCustomRotorTest;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, _GClass, AbLED, AbNumEdit, Vcl.ExtCtrls;

type
  TForm6 = class(TForm)
    btnVersion: TButton;
    Panel1: TPanel;
    ledResult: TAbLED;
    btnAND: TButton;
    ledB: TAbLED;
    ledA: TAbLED;
    Panel2: TPanel;
    ebResult: TEdit;
    ebB: TEdit;
    ebA: TEdit;
    btnAddDouble: TButton;
    Panel3: TPanel;
    btnReturnTwoStrings: TButton;
    lblString1: TLabel;
    lblString2: TLabel;
    Panel4: TPanel;
    AddIntegers: TButton;
    nsInt2: TAbNumSpin;
    nsInt1: TAbNumSpin;
    neResult: TAbNumEdit;
    btnMultiplyDoubles: TButton;
    btnGetAzimuth: TButton;
    lblGetAzimuth: TLabel;
    procedure btnAddDoubleClick(Sender: TObject);
    procedure AddIntegersClick(Sender: TObject);
    procedure btnANDClick(Sender: TObject);

    procedure btnReturnTwoStringsClick(Sender: TObject);
    procedure btnVersionClick(Sender: TObject);
    procedure ledAClick(Sender: TObject);
    procedure ledBClick(Sender: TObject);
    procedure btnMultiplyDoublesClick(Sender: TObject);
    procedure btnGetAzimuthClick(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form6: TForm6;

implementation

{$R *.dfm}

uses CustomRotorLibrary;

procedure TForm6.AddIntegersClick(Sender: TObject);
var
  Int1, int2: integer;
begin

  Int1 := nsInt1.ValueAsInt;
  int2 := nsInt2.ValueAsInt;

  // neResult.ValueAsInt := AddInt(Int1, int2);
end;

procedure TForm6.btnANDClick(Sender: TObject);
var
  res: boolean;
begin
  ledResult.Checked := ANDER(ledA.Checked, ledB.Checked);

end;

procedure TForm6.btnGetAzimuthClick(Sender: TObject);
begin
  lblGetAzimuth.caption := IntToStr(getAzimuth);
end;

procedure TForm6.btnMultiplyDoublesClick(Sender: TObject);
var
  a, b, Ans: double;
begin
  a := StrToFloat(ebA.Text);
  b := StrToFloat(ebB.Text);
  Ans := Multiply(a, b);
  ebResult.Text := FloatToStr(Ans);

end;

procedure TForm6.btnAddDoubleClick(Sender: TObject);
var
  a, b, Ans: double;
begin
  a := StrToFloat(ebA.Text);
  b := StrToFloat(ebB.Text);
  Ans := AddDouble(a, b);
  ebResult.Text := FloatToStr(Ans);
end;

procedure TForm6.btnReturnTwoStringsClick(Sender: TObject);
var
  buf1, buf2: array [0 .. 255] of Ansichar;

begin

  ReturnTwoStrings(buf1, buf2);
  lblString1.caption := lblString1.caption + ': ' + buf1;
  lblString2.caption := lblString2.caption + ': ' + buf2;

end;

procedure TForm6.btnVersionClick(Sender: TObject);
var
  buf1: array [0 .. 255] of Ansichar;
  numChar: integer;
  len: integer;
begin
  If Version(buf1, numChar) then
    ShowMessage('Version: ' + buf1 + ' and numChar = ' + IntToStr(numChar))
  else
    ShowMessage('Failure');
end;

procedure TForm6.ledAClick(Sender: TObject);
begin
  ledA.Checked := Not ledA.Checked;
end;

procedure TForm6.ledBClick(Sender: TObject);
begin
  ledB.Checked := NOT ledB.Checked;
end;

end.
