unit uForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Spin;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    SpinEdit1: TSpinEdit;
    Button5: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

  TNames = record
    id:integer;
    name, first: String[10];
    age: byte;
    female: boolean;
  end;

var
  Form1: TForm1;
  DatFile: File of TNames;

implementation

{$R *.DFM}

procedure TForm1.Button2Click(Sender: TObject);
begin
  AssignFile(DatFile,'E:\560\Daten\dings.dat');
  if FileExists('E:\560\Daten\dings.dat') then reset(DatFile) else rewrite(DatFile);
  CloseFile(DatFile);
end;

procedure TForm1.Button1Click(Sender: TObject);
var temp: TNames; sex:String; i:integer;
begin
  reset(DatFile);
  //sendmessage(Memo1.handle,EM_SETTABSTOPS,1,longint(7));
  Memo1.Lines.Clear;
  for i:=0 to FileSize(DatFile)-1 do
  //while not EoF(DatFile) do
    begin
      Read(DatFile,temp); if temp.female=true then sex:='f.' else sex:='m.';
      Memo1.Lines.Add(IntToStr(i)+': '+temp.name+', '+temp.first+' ('+IntToStr(temp.age)+') '+sex);
    end;
  CloseFile(DatFile);
end;

procedure TForm1.Button5Click(Sender: TObject);
var temp: TNames;
begin
  if Edit1.Text<>'' then
  begin
    temp.name:=Edit1.Text;
    temp.first:=Edit2.Text;
    temp.age:=SpinEdit1.Value;
    temp.female:=Radiobutton2.Checked;
    reset(DatFile);
    seek(DatFile,FileSize(DatFile)); Write(DatFile,temp); CloseFile(DatFile);
    Button1.Click;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AssignFile(DatFile,'E:\560\Daten\dings.dat');
  if not FileExists('E:\560\Daten\dings.dat') then rewrite(DatFile);
  Button1.Click;
end;

end.