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;
|