Best Ways to Save Objects with Coder Support
1 view (last 30 days)
I have a couple of custom classes I've made for my project and I am using Coder to run my code as an executable. I am processing segments of data and generating instances of my objects every few seconds. I want to save my objects during the run or after it has completed for archiving/debugging reasons. I don't see any Coder supported functions for this other than the low level fwrite or fprintf. My only idea so far is to write a script that reads all of the properties of my class, converts them to strings with sprintf, and then writes them to a file. This isn't a clean option and I'd like to know if there is a better way to write objects to disk that is supported for code generation.
FYI: my classes have properties that are mixed data types - some of doubles, some are strings, some are other objects.
I'm afraid the answer is 'Just write your own program that writes you objects to a file.' but I don't want to launch down that path until I've checked in with someone else who might know better than I.
Nathan S on 30 Aug 2022
Unfortunately, Coder doesn't have any good tools for this (aside from fwrite/fprintf). This is a common problem, and we know that Coder's workflows don't make it easy right now. Hopefully we can provide some better tools in a future release, although that doesn't help you much right now.