1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
//pour ecrire
procedure TForm1.Button1Click(Sender: TObject);
var
f:File of byte;
i,j,n:Integer;
t:array of PIntegerArray;
begin
ListBox2.Clear;
setlength(t,100);
assignfile(f,'c:\tata.edam');
rewrite(f);
for i:=0 to 100-1 do
begin
getmem(t[i],50*4);
for n:=0 to 50-1 do
begin
t[i,n]:= Trunc(random($FFFFF));
ListBox2.Items.Add(inttostr(t[i,n]));
end;
BlockWrite(f,t[i]^,50*4,j);
application.ProcessMessages;
end;
for i:=0 to 100-1 do
begin
FreeMem(t[i]);
end;
closefile(f);
end;
//pour lire
procedure TForm1.Button2Click(Sender: TObject);
var
f:File of byte;
i,j,n:Integer;
t:array of PIntegerArray;
begin
setlength(t,100);
assignfile(f,'c:\tata.edam');
{$i-}
reset(f);
if ioresult<>0 then exit;
ListBox1.Clear;
i:=0;
repeat
getmem(t[i],50*4);
BlockRead(f,t[i]^,50*4,j);
for n:=0 to 50-1 do
ListBox1.Items.Add(inttostr(t[i,n]));
inc(i);
application.ProcessMessages;
until (j=0) or (i>=100);
for i:=0 to 100-1 do
begin
FreeMem(t[i]);
end;
closefile(f);
end; |
Partager