using INIPUT to erase section from ini-file doesn't work

Previous topic - Next topic

BdR

I'm having trouble erasing a section from an ini-file.

I save the current gamestate to an inifile, so I can reload it at next startup. After it has been reloaded it needs to be removed from the file. So wanted to erase my "savestate" section using the INIPUT command. But this doesn't seem to work properly, it looks like a bug.

For example, my settings.ini file contains this:

[gamesettings]
x=4
y=4
[customsettings]
sound=off
[savestate]
level=2
time=831
moves=4


And when I run the following GLBasic code, the section is not removed from the ini-file. The filedate of the ini-file isn't even changed, so it looks like it's actually not doing anything.

Code (glbasic) Select

  INIOPEN PLATFORMINFO$("DOCUMENTS") + "/settings.ini"
  INIPUT "savestate", "", ""
  INIOPEN ""
  // nothing has happened, savestate section still exists


However, when I first change one of the values in the section and then erase it, then it does work. For example like this:

Code (glbasic) Select

  INIOPEN PLATFORMINFO$("DOCUMENTS") + "/settings.ini"
  INIPUT "savestate", "level", "1" // <- change one value
  INIPUT "savestate", "", ""
  INIOPEN ""
  // this works, savestate section is now removed


Some of my system info, maybe it will help:
Windows XP
GLBasic IDE, Version: 7.341
Configuration: WIN32
GPC - GLBasic Precompiler V.6.922 SN:******** - 3D, NET

MrTAToad

Yes - it appears that setting the key$ value to "" doesn't delete the section

Kitty Hello

The "changed" flag was not set internally. Try to really change a value (assign one to it's own value just to be safe) until the next update, please.