Programalama > DELPHI

Etiketler: binary, file, ile, çalismak

Ort. 0
Puan ver:
type
  TMember = record
    Name : string[50];
    eMail : string[30];
    Posts : LongInt;
  end;
  
 var Members : array[1..50] of TMember;


var F : file of TMember;


AssignFile(F, 'Members.dat')

var F : file of TMember;
begin
 AssignFile(F,'members.dat');
 Rewrite(F);
 try
  for i:= 1 to 50 do
   Write (F, Members[i]);
 finally
  CloseFile(F);
 end;
end;

 var Member: TMember
     F : file of TMember;
begin
 AssignFile(F,'members.dat');
 Reset(F);
 try
  while not Eof(F) do begin
   Read (F, Member);
 {  DoSomethingWithMember; }
  end;
 finally
  CloseFile(F);
 end;
end;

 
{go back to the beginning -  the first record}
Seek(F, 0);

{go to the 5-th record}
Seek(F, 5);

{Jump to the end - "after" the last record}
Seek(F, FileSize(F));

procedure ChangeEMail
  (const RecN : integer; const NewEMail : string);
var DummyMember : TMember;
begin
 {assign, open, exception handling block}
 Seek(F, RecN);
 Read(F, DummyMember);
 DummyMember.Email := NewEMail;
 {read moves to the next record, we have to
 go back to the original record, then write}
 Seek(F, RecN);
 Write(F, DummyMember);
 {close file}
end;



Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2024 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSOBİL projesidir.