home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1994 by Charles Calvert }
- { Project Name: TWOPOW2 }
-
- { This program demonstrates:
-
- * using for loops.
-
- * Setting a Default button for automatically responding
- to a press on the enter key.
-
- * Reporting errors when the user enters invalid data.
- }
-
-
- interface
-
- uses
- WinTypes, WinProcs,
- Classes, Graphics,
- Controls, StdCtrls,
- Printers, Forms, SysUtils, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- BCalc: TButton;
- Edit1: TEdit;
- Panel1: TPanel;
- Panel2: TPanel;
- Panel3: TPanel;
- procedure BCalcClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.BCalcClick(Sender: TObject);
- var
- i, j, k: LongInt;
- begin
- k := 1;
- j := StrToInt(Edit1.Text);
- if J > 30 then begin
- Panel2.Caption := 'Power too high';
- Exit;
- end;
- for i := 1 to j do
- k := k * 2;
- Panel2.Caption := IntToStr(k);
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Edit1.Text := '';
- end;
-
- end.
-