Sign in to follow this  
Followers 0
J0ker

Iniwrite Error

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I'm having a problem with an IniWrite. I have a file named config.ini and and when my script exit , it reset all variables to 0 in this file. The problem is if the config.ini file doesnt exit, it will create one and I DONT want that to happen. Is there anyway to prevent the script from creating the config.ini if it's not there?

Func Terminate()
    IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "First", "0")
    IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Second", "0")
    IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Third", "0")
    IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Fourth", "0")
    IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Fifth", "0")
    Exit(0)
EndFunc ;==> Terminate
Edited by J0ker

Share this post


Link to post
Share on other sites



You told it to do only that ... :whistle:

Just do:

Func Terminate()
    If FileExists(@SCRIPTDIR & "\Config.ini") Then
        IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "First", "0")
        IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Second", "0")
        IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Third", "0")
        IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Fourth", "0")
        IniWrite(@SCRIPTDIR & "\Config.ini", "Settings", "Fifth", "0")
    EndIf
    Exit(0)
EndFunc ;==> Terminate

[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

Thx Smoke! Why I did not think of that :whistle:

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