[Lazarus] Read/Write files question

Sven Barth pascaldragon at googlemail.com
Mon Apr 4 17:42:30 CEST 2011

Am 04.04.2011 16:50, schrieb Kjow:
> Hi all,
> I have a problem with write and read binary files. I can't understand
> where I'm in wrong... I hope you can help me.
> In a form I have 2 buttons, an edit and a memo.
> In the source I made a simple record:
>    TCustom1 = record
>      Test1: integer;
>      Test2: string;
>    end;

You must not use dynamic/managed types like strings, dynamic arrays, 
classes, etc. when using Read and/or Write. If you need strings then you 
must restrict yourself to ShortString. Otherwise you need to use 
TFileStream and read/write the file yourself.


> When I load the file, "i" has the right number of row (e.g. 150), but
> I get access violation.
> I can't understand where I'm in wrong, if in write or in read or
> both... I already used file access, but it worked everytime well...
> now I can't make it working.
> Thank you,
> Kjow
> PS Read/write could be used only with records or also with classes?

Only records as far as I'm aware of.


More information about the Lazarus mailing list