Sign in to follow this  
Followers 0
forger

IniDelete and IniWrite

8 posts in this topic

hey, I don't know if it's supposed to work this way, but if I use

IniWrite(blah.ini,bluh,"","")
IniDelete(blah.ini,bluh,"")

The iniwrite creates the file, the section, a blank key containing a blank value.

And inidelete doesn't clear the bluh section, but tries to clear an empty one (if I understood the meaning of the blank key). I have to use

IniDelete(blah.ini,blah)

Is anyone using a blank key?

Hence can you fix the IniWrite and IniDelete somehow to check if a key entry is blank and not create the key nor try to delete it?

I guess I could use some extra script lines on my behalf, but I don't see the point of creating/trying to delete a blank key :D Yet I use variables, something like this:

IniDelete($inifile2del, $inisection2del, $inikey2del)

and it would save me a bunch of lines where i check if $inikey2del = "" and overcome it.

:D Cheers!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Wow, I read this twice and still don't understand what your saying. Can you give an example of an ini section you don't want to delete (what it would look like) and one that you do want to delete?

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I knew this was going to happen lol, um.. OK

I'm not at home unfortunately, and my scripts are on the other hard disk :\

With

Dim $name = "name", $nvalue = "mary", $surname = "surname", $svalue = "johnson", $emptykey = "", $emptyvariable = ""

IniWrite("blah.ini","bluh",$name,$nvalue)
IniWrite("blah.ini","bluh",$surname,$svalue)
IniWrite("blah.ini","bluh",$emptykey,$emptyvariable)

a blah.ini is created:

[bluh]name=mary

surname=johnson

=

That's what I mean by blank key, it just adds an equal sign there.

Now if I use

IniDelete("blah.ini","bluh",$emptykey)

this is left:

[bluh]name=mary

surname=johnson

meaning it only deletes the empty key when I pass the $emptykey field in IniDelete.

For IniWrite: I expected it not to create the line with the equal sign. What's the point of creating it if the key is empty?

For IniDelete: I wanted it to delete the whole section even when I pass the empty variable.

Share this post


Link to post
Share on other sites

I pass in variables. if the key & value variables are empty, then sometimes it could come out like "=". My exact question is shouldn't IniWrite function detect that somehow? :D

Share this post


Link to post
Share on other sites

I pass in variables. if the key & value variables are empty, then sometimes it could come out like "=". My exact question is shouldn't IniWrite function detect that somehow? :D

Shouldn't you detect it? You are the one who doesn't want it there so validate your input. If you want to make the invariant that the key is empty, enforce it. As far as I'm concerned, since all the INI functions handle it correctly, there's no problem here.

Share this post


Link to post
Share on other sites

Ok thanks :D

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