Problem with loading/saving

Blitz3D Forums/Blitz3D Programming/Problem with loading/saving

Farflame(Posted 2006) [#1]
Ok, been banging my head against the wall for a week with this one. My program is huge so I can't show you any code, but hopefully the problem might trigger some ideas from somebody.

Here's what's happening.....

I'm loading alot (about 50k) of info from disk to a type. The info is then being updated slightly, then saved back to disk. The routines to do all this are working fine as far as I'm concerned, because they're used in various parts of my program and have been working correctly for ages.

After that, the files are closed and my program continues.

However, upon loading the info again, I see that the updated info isn't there. This is very odd, because as I say, the load/save routines are fine (I'm 99% sure of that). I've checked the info IMMEDIATELY after closing the file (reopened it and reloaded it again) and the updated info isn't updated at all.

I can only assume I'm doing something wrong with the closing of my files. If I don't close them at the correct place, am I right in saying the file won't get updated? Is there any other reason that anyone can think of why a save operation won't work (bearing in mind that other save operations are still working in the same program)?

I realise I'm not giving you much to go on, but any ideas will be appreciated.


Farflame(Posted 2006) [#2]
Good lord, I don't know what it is, but that's twice I've done this. Simply by typing out my problem, I've worked it out (30 seconds later). Sorry about that, please feel free to delete this topic.

I was using Readfile......... (puts gun to head)......


fredborg(Posted 2006) [#3]
- Assuming you are using WriteFile(filename$) for writing the file, make sure it returns a non zero value.

- Run everything in debug.

- Make sure the file you are writing to is not a read-only file.

- Make sure you are writing to the correct file.

Your file write code should look something like this:

f = WriteFile("hubba.txt")
If f
  ; Write everything here, using writeline(f,"hello"), writestring(f,"world") etc.
  
  CloseFile f
Else
  RuntimeError "Yo, couldn't write the file...fishy, innit?"
EndIf