Thema: Delphi Hilfe mit Dateien

Einzelnen Beitrag anzeigen

Benutzerbild von qb-tim
qb-tim

Registriert seit: 3. Mär 2006
Ort: Deutschland
280 Beiträge
 
Delphi 6 Professional
 
#10

Re: Hilfe mit Dateien

  Alt 17. Mai 2006, 14:37
Danke himitsu

Die Befehle habe ich gesucht!

Mein Programm sieht jetzt so aus:

Delphi-Quellcode:
procedure TForm1.FormActivate(Sender: TObject);
var x, y : Integer;
begin
  for x := 1 to 9 do
    for y := 1 to 9 do
    begin
      Edit[x, y] := TEdit.Create(Self);
      Edit[x, y].Parent := Form1;
      Edit[x, y].Height := 25;
      Edit[x, y].Width := 25;
      Edit[x, y].Text := '0';
    end;
  for x := 1 to 9 do
  begin
    Edit[x, 1].Top := 8;
    Edit[x, 2].Top := 32;
    Edit[x, 3].Top := 56;
    Edit[x, 4].Top := 88;
    Edit[x, 5].Top := 112;
    Edit[x, 6].Top := 136;
    Edit[x, 7].Top := 168;
    Edit[x, 8].Top := 192;
    Edit[x, 9].Top := 216;
  end;
  for y := 1 to 9 do
  begin
    Edit[1, y].Left := 8;
    Edit[2, y].Left := 32;
    Edit[3, y].Left := 56;
    Edit[4, y].Left := 88;
    Edit[5, y].Left := 112;
    Edit[6, y].Left := 136;
    Edit[7, y].Left := 168;
    Edit[8, y].Left := 192;
    Edit[9, y].Left := 216;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
Var x, y, z : Integer;
Var tmp : String;
Var myFile: File of Integer;

begin

tmp := Edit1.Text;

//schreiben
AssignFile(myFile, tmp);
Rewrite(myFile);
for x := 1 to 9 do
  for y := 1 to 9 do
  begin
    z := StrToInt(Edit[x,y].Text);
    Write(myFile, z);
  end;
CloseFile(myFile);

//lesen
AssignFile(myFile, tmp);
Reset(myFile);
for x := 1 to 9 do
  for y := 1 to 9 do
  begin
    Read(myFile, z);
    Edit[x,y].Text := IntToStr(z);
    if z = 0 then
      Edit[x,y].Text := '';
  end;
CloseFile(myFile);

end;
Es ist nur ein Testprogramm also ist es nichts Bewundernswertes...

  Mit Zitat antworten Zitat