Jump to content

IniWrite() overwriting key?


Recommended Posts

Hi,

IniWrite() is overwriting the key?, below is my code:

IniWrite(@ScriptDir & "\php\php.ini", "Zend", "zend_extension_ts", '"' & @ScriptDir & '\Files\filename1.dll"')
        
IniWrite(@ScriptDir & "\php\php.ini", "Zend", "zend_extension_ts", '"' & @ScriptDir & '\Files\filename2.dll"')
    
//line 2 is overwriting the line 1?

It outputs the following within the php.ini:

[Zend]  
zend_extension_ts="C:\Documents and Settings\App\Files\filename2.dll"

When it should output the following:

[Zend]  
zend_extension_ts="C:\Documents and Settings\App\Files\filename1.dll"
zend_extension_ts="C:\Documents and Settings\App\Files\filename2.dll"

Theirfore; how can I achieve the above output - can someone post some example code please, as I can't see anything on this on the documentation page?

Edited by newbtophpautoit
Link to comment
Share on other sites

  • Developers

You cannot have duplicated keywords in the same INI file Section.

When this is really needed you will have to use FileWriteLine() to write the records yourself.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You cannot have duplicated keywords in the same INI file Section.

When this is really needed you will have to use FileWriteLine() to write the records yourself.

Jos

Jos thanks for the swift response :x

Im fairly new to AutoIt, do you mind providing a basic example of how I'd use FileWriteLine() according to my current code? (I'd like at it to the end of the ini file)

Appreciate your help!

Edited by newbtophpautoit
Link to comment
Share on other sites

  • Developers

when the file needs to be created just use these 3 lines:

FileWriteLine(@ScriptDir & "\php\php.ini","[Zend]")  
FileWriteLine(@ScriptDir & "\php\php.ini",'zend_extension_ts="C:\Documents and Settings\App\Files\filename1.dll"')
FileWriteLine(@ScriptDir & "\php\php.ini",'zend_extension_ts="C:\Documents and Settings\App\Files\filename2.dll"')

Just do some reading in the supplied helpfile on how to write information to files.

Do you need to update these lines every time the script is ran?

Are there other lines in the INI file or are these the only records? (If so you could just override the whole file)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

when the file needs to be created just use these 3 lines:

FileWriteLine(@ScriptDir & "\php\php.ini","[Zend]")  
FileWriteLine(@ScriptDir & "\php\php.ini",'zend_extension_ts="C:\Documents and Settings\App\Files\filename1.dll"')
FileWriteLine(@ScriptDir & "\php\php.ini",'zend_extension_ts="C:\Documents and Settings\App\Files\filename2.dll"')

Just do some reading in the supplied helpfile on how to write information to files.

Do you need to update these lines every time the script is ran?

Are there other lines in the INI file or are these the only records? (If so you could just override the whole file)

Jos

I only need to update them lines once, and their their are other lines in the INI file.
Link to comment
Share on other sites

  • Developers

I only need to update them lines once, and their their are other lines in the INI file.

What I would do is to do a fileopen() on the INI file in Read mode... then loop a Filereadline() testing the content that needs to be replaced and doing a fileWriteLine() to a Temp file. When done copy the Temp file to the INI file.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...