Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var MFile:file;
var i1,tmp:integer;
begin
randomize;
AssignFile(MFile,'cisla.bin');
rewrite(MFile,1);
for i1:=1 to 25 do
begin
tmp:=random(500);
BlockWrite(MFile,tmp,SizeOf(Integer));
Memo1.Lines.Append(IntToStr(tmp));
end;
//CloseFile(MFile);
reset(MFile,1);
while not eof(MFile) do
begin
BlockRead(MFile,tmp,SizeOf(Integer));
Memo2.Lines.Append(IntToStr(tmp));
end;
CloseFile(MFile);
end;
procedure TForm1.Button3Click(Sender: TObject);
var MFile:File;
tmp:integer;
begin
AssignFile(MFile,'cisla.bin');
reset(MFile,1);
//showmessage('1');
while not(eof(MFile)) do
begin
//showmessage('2');
BlockRead(MFile,tmp,SizeOf(Integer));
//showmessage('3');
Memo3.Lines.Append(IntToStr(tmp));
//showmessage('4');
end;
closefile(MFile);
end;
thank you marabu, this finaly worked
but iam not geting it why i had to use the 1 in reset(MFile,1); and rewrite(); and also why was the first read successfull and the 2 one failed failed?