unit Unit11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
MAXNAMES = 3;
type
TForm11 =
class(TForm)
edtName: TEdit;
btnSave: TButton;
btnShowNameList: TButton;
btnClearList: TButton;
Label1: TLabel;
procedure btnClearListClick(Sender: TObject);
procedure btnShowNameListClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
Names:
array[0..MAXNAMES - 1]
of string;
CurrentIndex: Cardinal;
public
{ Public-Deklarationen }
end;
var
Form11: TForm11;
implementation
{$R *.dfm}
procedure TForm11.btnClearListClick(Sender: TObject);
var
i: Integer;
begin
for i := 0
to High(Names)
do
Names[i] := '
';
CurrentIndex := 0;
end;
procedure TForm11.btnSaveClick(Sender: TObject);
begin
btnSave.enabled := CurrentIndex < MAXNAMES - 1;
edtName.enabled := CurrentIndex < MAXNAMES - 1;
Names[CurrentIndex] := edtName.Text;
if CurrentIndex < MAXNAMES - 1
then
begin
Inc(CurrentIndex);
edtName.Clear;
edtName.SetFocus;
end;
end;
procedure TForm11.btnShowNameListClick(Sender: TObject);
var
i: Integer;
NameList:
string;
begin
for i := 0
to High(names)
do
begin
NameList := NameList + Names[i] + #13#10;
end;
ShowMessage(NameList);
end;
procedure TForm11.FormCreate(Sender: TObject);
begin
CurrentIndex := 0;
end;
end.