Hello, basically I am making a program which uses OOP to draw objects onto a canvas and they constantly move, I am making a feature which will save the position variables as the objects move each time and then once a file is outputted it can be read again and the objects can be spawned and moved in the exact same locations.

The problem I have is decided on the best solution as I am new to OOP, I was thinking I could store all the location variables in a separate Type Record and constantly BlockWrite that data, possibly using a dynamic array. But I am having problems with BlockWrite and it is slightly buggy in my prototype scripts as the pointers end up causing read and write errors with the dynamic array.

I was thinking should I carry on trying to use BlockWrite and if so can someone help me with some code which could use dynamic arrays to store data like this. Or should I look into another way of saving such as Object Persistence and keep all variables inside the Object Class? (including the movement ones).

Edit: The problem with the dynamic array is that it wipes the data of the counter variables after calling BlockRead, which tells me how many arrays were made and how many need to be displayed/read, it changes the value to anything, pretty much erases it.

Edited by DelphiGuy: n/a

5 Years
Discussion Span
Last Post by pritaeas

It's hard to make a design choice for you, but if I were to do this, I'd probably store it in the class. If the class is designed correctly, you can just stream the entire object to file/stream, and read it back in again (WriteComponent/ReadComponent).


Ye that's what I was thinking but the class has moving objects, i.e. changing variables and it needs to record all the different changes so would I have to WriteComponent each time and would it append the data?


Yes you would. Are you trying to log the movement of all your objects? Then perhaps a logger object as an intermediate can help you. Each moving objects writes to a queue (in memory), and your logger objects reads this and appends to a file at regular intervals. This can be a good solution if you have lots of data.

Votes + Comments
Thank you!

Ye that sounds like a much more suitable solution, have you got any example codes or websites with intros to this?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.