Jump to content
Sign in to follow this  
J0ker

Iniwrite Error

Recommended Posts

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

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.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...