Sign in to follow this  

Weird Problem with Saving Structures in Delphi

This topic is 3487 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

This topic is 3487 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this