Weird Problem with Saving Structures in Delphi

Started by
-1 comments, last by Destriarch 15 years, 11 months ago
Ok, I'm writing a small graphical application, and I need to save some of its results in a format that I can load again later. However I've come across a very, very strange bug that I just can't fathom. If I save my file, clear the screen then load it back in again, then my data is restored just dandy without a problem. If however I save some data, close the program, restart it and then reload the data, it comes up with errors. The errors occur as soon as the program tries to load a record-type structure, anything prior to that saves and loads just fine. The loading code goes like this: myfile := tfilestream.Create(filename,fmopenread); temp := readstring(myfile); {ReadString is a function for easy loading and saving strings to a stream. This works perfectly, don't worry about it.} if temp = 'Universe' then begin {checking to make sure the file is of the correct type - works fine.} myfile.ReadBuffer(l,1); myfile.ReadBuffer(ncol,1); myfile.ReadBuffer(nrow,1); {reading in details on how many records it needs to check. Fine.} for n := 1 to (ncol * nrow) do begin myfile.readBuffer(current,32); {This is where things go wrong, usually in the form of inaccessible data.} sector.AddWorld(current); {Special code by Ranger, which allows the creation of lists of records. Works fine.} end; {code doesn't even get this far.} temp := readstring(myfile); while temp <> '[End of Universe]' do begin routelist.Add(temp); temp := readstring(myfile); end; end; myfile.free; Can anyone guess what is going wrong here? I'm running out of ideas. It's probably something really simple and I'm just too close to see it. Ash

This topic is closed to new replies.

Advertisement