![]() |
Re: Untyped Binary Files
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? |
Re: Untyped Binary Files
Zitat:
I don't really now how it works, but the Delphi help says...ehm...damn, i've got the german version. So no quotation. :wink: The help says that "only a blocksize of 1 will almost every time lead to a correct size." And I guess that this has also to do with the size of your buffer you are using in
Delphi-Quellcode:
because this is also 1.
BlockRead(MFile,tmp,1);
So long, Daniel |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:55 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz