Sign in to follow this  
Followers 0
newbtophpautoit

IniWrite() overwriting key?

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Hmm, this seems to work:

FileWriteLine(@ScriptDir & "\php\php.ini", 'zend_extension_ts="' & @ScriptDir & '\Files\filename2.dll"')

However now it add that everytime the app opens - is their a way around that ie. perhaps replacing instead of adding or something? :/

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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