Delphi-Quellcode:
type TDatensatz = record
vorname: string[25];
nachname: string[25];
tag: integer;
monat: integer;
jahr: integer;
bild: string[100];
end;
var Tabelle: Array of TDatensatz;
//...
procedure SaveToFile(Dest: string);
var f: file of TDatensatz;
I: Cardinal;
begin
try
assignFile(f, Dest);
reWrite(f); //oder reset(f)
for I := low(Tabelle) to high(Tabelle) do
write(f, Tabelle[i]);
finally
closeFile(f);
end;
end;
function LoadFromFile(Source: string);
var f: file of TDatensatz;
I: Cardinal;
begin
I := 0;
try
assignFile(f, Source);
reset(f);
SetLength(Tabelle, FileSize(f));
while not eof(f) do
begin
read(f, Tabelle[I]);
Inc(I);
end;
finally
closeFile(f);
end;
end;
procedure irgendwas;
begin
LoadFromFile('C:\Test.dat');
if high(Tabelle) > 0 then
begin
Tabelle[0].Vorname := editVorname.text;
editNachname.Text := Tabelle[0].Nachname;
end;
SaveToFile('C:\Test.dat');
end;
[edit] paar fehler beseitigt^^[/edit]