Re: Delphi multi-TList data file

Posted by webmaster Guido on April 18, 2001

In Reply to: multi-TList data file posted by eeleong on April 12, 2001

: I have create an data-structure using TList, but have problem save it into file.

: ....
: Data Structure is something like this,

: A:TList;
: B:TList
: C:TList
: D:TResullt

: TResult=class(TPersistent)
: begin
: Property FValue;
: Property FResult;

: end;

: .......

I'm not repeating your entire text here, it's more like an article instead of a question ;-)

Anyhow, some thoughts:
1. You're trying to save lists of lists of lists of "pointers", instead of saving the objects' "properties" (fields).
2. Handling TResult as a record fails, because for a record you have to define the dimensions (sizes) of its fields.

So, you have to choose:

a. Either define the maximum sizes of the fields of fixed size records in which you save the objects' properties (and fill the rest with fill-characters) -- but this can waste a lot of disk space;

b. Or use *separators* in the file;

c. Or develop a system of file-headers, that describes how many objects there are in the file, what type an object is, how big the "chunk" for every object is, and so on...

(b) and (c) are in fact what Delphi does for saving forms and components in DFM-files.

Related Articles and Replies: