Jump to content
  • Advertisement
Sign in to follow this  

Weird Problem with Saving Structures in Delphi

This topic is 3793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!