CubicDesign wrote:
> I want to save a form with all data inserted by user (in multiple boxes 
> and grids).
> For this, I have added to all controls a procedure 
> SaveToFile/LoadFromFile (like in TStringList.SaveToFile).
> All is working nice with one single exception: I have too many files 
> instead of a single one and the user will be confused.
> 
> My idea was to compress all those files in a single ZIP/RAR in the fly 
> or at least to compact them (like TAR).

Tar doesn't compact. It concatenates.

You can concatenate, too. Instead of SaveToFile, write SaveToStream.

If you want, you can make each stream reader able to know how much of 
the data belongs to it. It will need to know when to stop reading from 
the stream. It cannot simply read until it reaches the end since there 
will be other controls' data on the stream as well. You can do this by 
writing a length value to the stream before writing the data. Then when 
you read the data, read the length value first and only read the 
indicated amount.

You can also shield all the other writers from having to know about each 
other. Have a driver function that creates a separate TMemoryStream for 
each control and then incorporates them into the main stream using the 
technique I described above.

-- 
Rob
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to