Sign in to follow this  
Followers 0
chssoccer

INI problem... - Solved

11 posts in this topic

#1 ·  Posted (edited)

How do I clear a section where there is nothing left in that section of the INI?

Edited by chssoccer

Share this post


Link to post
Share on other sites



How do I clear a section where there is nothing left in that section of the INI?

Try IniDelete without specifying a key. See the help file.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Try IniDelete without specifying a key. See the help file.

no that didn't work...

Share this post


Link to post
Share on other sites

Works fine for me.

IniWrite("test.ini","test1", "key1", "value1")
IniWrite("test.ini","test2", "key2", "value2")
IniWrite("test.ini","test3", "key3", "value3")
IniDelete("test.ini", "test2")

Share this post


Link to post
Share on other sites

Works fine for me.

IniWrite("test.ini","test1", "key1", "value1")
IniWrite("test.ini","test2", "key2", "value2")
IniWrite("test.ini","test3", "key3", "value3")
IniDelete("test.ini", "test2")
That deletes the section, but I just want to delete everything in the section

Share this post


Link to post
Share on other sites

Are you saying you want to set all of the keys to blank values?

Share this post


Link to post
Share on other sites

Are you saying you want to set all of the keys to blank values?

No I want nothing in the section. Just to clear it completely. No keys, no values.

Share this post


Link to post
Share on other sites

Dude, if you use the IniDelete example I showed then it doesn't matter if the section name remains or not, if something attempts to write to that section it will recreate it.

Share this post


Link to post
Share on other sites

Dude, if you use the IniDelete example I showed then it doesn't matter if the section name remains or not, if something attempts to write to that section it will recreate it.

Oh ok.

Share this post


Link to post
Share on other sites

If you absolutely need to retain the section name I think you can do...

$var = IniReadSection("test.ini", "section2")
If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $var[0][0]
        IniDelete( "test.ini", "section2", $var[$i][0])
    Next
EndIf

Share this post


Link to post
Share on other sites

Also if you search example scripts you will find a couple of INI Udfs. One by myself and 1 by Smoke_N. I think one of us might have been smart enough to add in an _INI_DeleteKey() function. On the other hand I don't remember for sure. It wouldn't be difficult to do though.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

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  
Followers 0