home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: MOREFUNC }
-
- { Examples of calling some of the functions in
- the MATHBOX unit. Be sure MATHBOX is on your
- Library Path in the Options | Environment | Library Path
- menu option. }
-
- interface
-
- uses
- WinTypes, WinProcs, Classes,
- Graphics, Controls, Forms,
- StdCtrls, ExtCtrls;
-
- type
- TCalcType = (TXToTheY, TArcSin, TArcCos, TLogXY);
-
- type
- TForm1 = class(TForm)
- BCalc: TButton;
- Panel1: TPanel;
- Edit1: TEdit;
- Edit2: TEdit;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Panel2: TPanel;
- RBXToTheY: TRadioButton;
- RBArcSin: TRadioButton;
- RBArcCos: TRadioButton;
- RBLogYX: TRadioButton;
- BClose: TButton;
- procedure BCalcClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure RBClick(Sender: TObject);
- procedure BCloseClick(Sender: TObject);
- private
- CalcType: TCalcType;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses
- MathBox;
-
- {$R *.DFM}
-
- procedure TForm1.BCalcClick(Sender: TObject);
- var
- r, x, y: Real;
- begin
- x := Str2Real(Edit1.Text);
- y := Str2Real(Edit2.Text);
- Label1.Caption := 'Invalid Input';
- case CalcType of
- TXToTheY: r := XToTheY(x, y);
- TArcSin: if (x < 1.0) and (x > -1.0) then
- r := ArcSin(x)
- else
- Exit;
- TArcCos: if (x < 1.0) and (x > -1.0) then
- r := ArcCos(x)
- else
- Exit;
- TLogXY: if y <> 1 then
- r := LogXY(x, y);
- else
- Exit;
- end;
- Label1.Caption := Real2Str(r, 2 ,2);
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Edit1.Text := '';
- Edit2.Text := '';
- Label1.Caption := '';
- RBXToTheY.Checked := True;
- CalcType := TXToTheY;
- end;
-
- procedure TForm1.RBClick(Sender: TObject);
- begin
- CalcType := TCalcType((Sender as TRadioButton).Tag);
- end;
-
- procedure TForm1.BCloseClick(Sender: TObject);
- begin
- Close;
- end;
-
- end.
-