Saving Objects To A File

BlitzMax Forums/BlitzMax Beginners Area/Saving Objects To A File

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

z80jim, I'm trying exactly the same thing at the moment.
I have tried...
mynew:Ttest = new Ttest
field blah, blah blah
end type.
local Myptr:byte ptr = byte ptr(mynew)
myfile:tStream=writefile("output.dat")
for count = 0 to sizeof(mynew)
  writebyte(myfile,myptr[count]
next
closefile myfile.

<this is from scratch rather than an actual program>
However, checking the output file using Hex Editor shows some of the characters transposed.
Not sure why yet but it might be the fact I have the wrong field type in my Object (long story).
You might want to try it and see what happens but, it's likely, an instance isn't in contiguous memory.
<edit> Hmmm, might try...
Local mybank:TBank=CreateStaticBank(mynew,SizeOf(mynew))
Local myfile:TStream=WriteStream("decs1.txt")
WriteBank(mybank,myfile,0,SizeOf(mynews))
CloseFile myfile