Thema: Delphi Untyped Binary Files

Einzelnen Beitrag anzeigen

Benutzerbild von sk.Silvia
sk.Silvia

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

Re: Untyped Binary Files

  Alt 21. Feb 2006, 13:37
iam starting to get crazy :

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,1);
    Memo1.Lines.Append(IntToStr(tmp));
    end;

  //CloseFile(MFile);

  reset(MFile,1);
  while not eof(MFile) do
    begin
    BlockRead(MFile,tmp,1);
    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);
  
  while not(eof(MFile)) do
    begin
    BlockRead(MFile,tmp,1);
    Memo3.Lines.Append(IntToStr(tmp));
    end;

  closefile(MFile);
  end;
i used a block in size 1 but OMG :
output by writing (Memo1)-procedure TForm1.Button1Click(Sender: TObject); :
17,357,77,42,55,109,80,383,443,142,66,248,109,11,3 00,299,453,37,344,10,497,9,411,124,295
output by reading (Memo2)-procedure TForm1.Button1Click(Sender: TObject); :
17,357,77,42,55,109,80,383,443,142,66,248,109,11,3 00,299,453,37,344,10,497,9,411,124,295
output by reading (Memo3)-procedure TForm1.Button3Click(Sender: TObject); :
4384017,4384101,4384077,4384042,4384055,4384109,43 84080,4384127,4384187,4384142,4384066,4384248,4384 109,4384011,4384044,4384043,4384197,
4384037,4384088,4384010,4384241,4384009,4384155,43 84124,4384039

why i get different outputs by using the same algorithm???
  Mit Zitat antworten Zitat