Delphide binary dosyalarla çalışma - Delphi / Kylix Webmaster bilgi bankası, knowledge base Webmaster Araçları

AnaSayfa > Delphi / Kylix > Delphide binary dosyalarla çalışma
Kategori: Delphi / Kylix
Gönderen: Admin
Tarih: 2011-02-20
Puan: 6   Puan:6 | Katılımcı:4 | Katılımcı : 4
Okunma: 7082
  
 
1 puan 2 puan 3 puan 4 puan 5 puan 6 puan 7 puan 8 puan 9 puan 10 puan

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
Henüz Kimse Yorum Yapmamış, ilk yorumu siz ekleyin!
Yorum Ekleme Aparatı
Yorum Eklemek için lütfen sol menuden giris yapınız..
Toplam 0 yorum listelendi.