home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: REALSTR2}
-
- { Shows how to call routines stored in a unit. To
- run this program, the MATHBOX unit must be on
- your Library Path, as defined in the Options |
- Environment | Library menu choice. MATHBOX is
- stored in the UNITS subdirectory that ships
- with this book.
-
- Cosmetic issues:
- To align a label on a panel, remember that you
- can grow or shrink a control one pixel at a
- time by holding down the shift key and
- pressing the arrow keys. If you want to
- move a control on pixel at a time, hold
- down the control key and press the arrow
- keys.
- }
-
-
- interface
-
- uses
- MathBox, WinTypes, WinProcs,
- Classes, Graphics, StdCtrls,
- Controls, Forms, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- Edit1: TEdit;
- Label2: TLabel;
- Label4: TLabel;
- BCalc: TButton;
- Panel1: TPanel;
- LSquare: TLabel;
- Panel2: TPanel;
- LSquareRoot: TLabel;
- procedure BCalcClick(Sender: TObject);
- procedure FormActivate(Sender: TObject; Activating: Boolean);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.BCalcClick(Sender: TObject);
- var
- R: Real;
- begin
- R := Str2Real(Edit1.Text);
- LSquare.Caption := Real2Str(Sqr(R),2,2);
- LSquareRoot.Caption := Real2Str(Sqrt(R),2,2);
- Edit1.SelectAll;
- Edit1.SetFocus;
- end;
-
- procedure TForm1.FormActivate(Sender: TObject; Activating: Boolean);
- begin
- Edit1.SelectAll;
- Edit1.SetFocus;
- end;
-
- begin
- end.
-