[pascal]GTRPG_MAP_TILE_ANIMATION_VER1 = record
ACTIVE : BOOLEAN; // Animation Active?
TILES : TSTRINGLIST; // Tiles in animation
INDEX : INTEGER; // Current Tile Displayed
end; [/pascal]

I just saw this bit of code and this will also cause you some problems. String lists just like strings themselve have a variable length depending on how many entries they have. To store this record in a stream I suggest you do something like this:

[pascal]GTRPG_MAP_TILE_ANIMATION_VER1 = record
ACTIVE : BOOLEAN; // Animation Active?
INDEX : INTEGER; // Current Tile Displayed
TILELISTSIZE: INTEGER; // <--- New stuff
TILELISTOFFSET: INT64; // <--- New stuff
end; [/pascal]

Note that this won't save the string list yet. The idea is that instead of storing the tile list itself in the record, you only store the size of the tile list and the offest (which is the position of the the list in your file).

So you'd have to find out how big all your records are (if you convert all your strings to null-terminated ones you can use the SizeOf function to get the size).
The next thing you have to do is find out how big your tile lists are. The SizeOf operator won't work for that (it will only return the size of the pointer which is always 4 bytes). Here's a very dirty solution for that problem:

[pascal]
var
MyStringList: TStringList;
MyMemoryStream: TMemoryStream;
begin
MyStringList := TStringList.Create;
FillThis(MyStringList); // Just some bogus procedure that fills the string list
MyMemoryStream := TMemoryStream.Create;
MyMemoryStream.Clear;
MyMemoryStream.Seek(0, soFromBeginning);
MyStringList.SaveToStream(MyMemoryStream);
end;
[/pascal]

To obtain the size of the memory stream, use the size property of the memory stream (MyMemoryStream.Size).

With the size of the records you can calculate an offset and store it in the GTRPG_MAP_TILE_ANIMATION_VER1 record.
After you have written all records to your file, you can then write the stringlists to it one after the other.


This sounds like a lot of work and as matter of fact it is
Unless you completely re-structure your records, I don't see how you could do it differently though.

Another solution of saving structures of arbitrary length to a stream which involves some "abuse" is to turn all your records into TComponents and to then use the SaveComponentRes method of TFileStream... it works really well and will save you some trouble.
Note that only published properties will be saved to the stream...
If you need to store lists of records try using TCollections instead.
It works but of course it's a hack...[/b]