Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.04.22;
Скачать: CL | DM;

Вниз

Чтение записей из файла   Найти похожие ветки 

 
Lame1   (2002-04-10 13:21) [12]

Просто хотел спросить: этот код работает потому-что он правильный или потому-что я неправильный?

type TTestRec = record
StrLength: integer;
Path: string;
StrLength2: integer;
Path2: string;
end;

const filename= "C:\tst.txt";

procedure TForm1.btnWriteClick(Sender: TObject);
var f: TFileStream;
rec: TTestRec;
begin
f:= TFileStream.Create(filename, fmCreate);
try
rec.Path:= "line1";
rec.StrLength:= length(rec.Path);
rec.Path2:= "line2";
rec.StrLength2:= length(rec.Path2);
f.WriteBuffer(rec.StrLength, sizeof(rec.StrLength));
f.WriteBuffer(rec.Path, length(rec.Path));
f.WriteBuffer(rec.StrLength2, sizeof(rec.StrLength2));
f.WriteBuffer(rec.Path2, length(rec.Path2));
finally f.Free end;
end;

procedure TForm1.btnReadClick(Sender: TObject);
var f: TFileStream;
rec: TTestRec;
begin
f:= TFileStream.Create(filename, fmOpenRead);
try
f.ReadBuffer(rec.StrLength, sizeof(rec.StrLength));
f.ReadBuffer(rec.Path, rec.StrLength);
f.ReadBuffer(rec.StrLength2, sizeof(rec.StrLength2));
f.ReadBuffer(rec.Path, rec.StrLength2);
finally f.Free end;
end;



Страницы: 1 вся ветка

Текущий архив: 2002.04.22;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.022 c
6-69956
Niflhelmr
2002-02-11 16:17
2002.04.22
LDAP components?


6-69964
Stalko
2002-02-07 20:48
2002.04.22
Докачка файлов по HTTP


3-69671
alexandervasjuk
2002-04-03 12:41
2002.04.22
Извините, что я к вам обращаюсь... (IBDataSet : Master-Slave)


14-70018
Alexandr
2002-03-15 11:38
2002.04.22
Поцарапанный экран монитора


3-69749
Mike S
2002-04-02 15:14
2002.04.22
Редактирование в DBGrid