AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Untyped Binary Files

Ein Thema von sk.Silvia · begonnen am 19. Feb 2006 · letzter Beitrag vom 21. Feb 2006
Antwort Antwort
Seite 2 von 2     12   
Benutzerbild von sk.Silvia
sk.Silvia

Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
 
Delphi 7 Personal
 
#11

Re: Untyped Binary Files

  Alt 21. Feb 2006, 19:20
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?
  Mit Zitat antworten Zitat
Daniel G
(Gast)

n/a Beiträge
 
#12

Re: Untyped Binary Files

  Alt 21. Feb 2006, 20:14
Zitat von sk.Silvia:
but iam not geting it why i had to use the 1 in reset(MFile,1); and rewrite();
'Cause you are working with untyped files.

I don't really now how it works, but the Delphi help says...ehm...damn, i've got the german version. So no quotation.

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

BlockRead(MFile,tmp,1); because this is also 1.


So long,
Daniel
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 2     12   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:01 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz