home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / chap11 / realstr2 / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.5 KB  |  72 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: REALSTR2}
  5.  
  6. { Shows how to call routines stored in a unit. To
  7.   run this program, the MATHBOX unit must be on
  8.   your Library Path, as defined in the Options |
  9.   Environment | Library menu choice. MATHBOX is
  10.   stored in the UNITS subdirectory that ships
  11.   with this book.
  12.  
  13.   Cosmetic issues:
  14.     To align a label on a panel, remember that you
  15.     can grow or shrink a control one pixel at a
  16.     time by holding down the shift key and
  17.     pressing the arrow keys. If you want to
  18.     move a control on pixel at a time, hold
  19.     down the control key and press the arrow
  20.     keys.
  21. }
  22.  
  23.  
  24. interface
  25.  
  26. uses
  27.   MathBox, WinTypes, WinProcs,
  28.   Classes, Graphics, StdCtrls,
  29.   Controls, Forms, ExtCtrls;
  30.  
  31. type
  32.   TForm1 = class(TForm)
  33.     Label1: TLabel;
  34.     Edit1: TEdit;
  35.     Label2: TLabel;
  36.     Label4: TLabel;
  37.     BCalc: TButton;
  38.     Panel1: TPanel;
  39.     LSquare: TLabel;
  40.     Panel2: TPanel;
  41.     LSquareRoot: TLabel;
  42.     procedure BCalcClick(Sender: TObject);
  43.     procedure FormActivate(Sender: TObject; Activating: Boolean);
  44.   end;
  45.  
  46. var
  47.   Form1: TForm1;
  48.  
  49. implementation
  50.  
  51. {$R *.DFM}
  52.  
  53. procedure TForm1.BCalcClick(Sender: TObject);
  54. var
  55.   R: Real;
  56. begin
  57.   R := Str2Real(Edit1.Text);
  58.   LSquare.Caption := Real2Str(Sqr(R),2,2);
  59.   LSquareRoot.Caption := Real2Str(Sqrt(R),2,2);
  60.   Edit1.SelectAll;
  61.   Edit1.SetFocus;  
  62. end;
  63.  
  64. procedure TForm1.FormActivate(Sender: TObject; Activating: Boolean);
  65. begin
  66.   Edit1.SelectAll;
  67.   Edit1.SetFocus;
  68. end;
  69.  
  70. begin
  71. end.
  72.