newbtophpautoit Posted December 15, 2010 Share Posted December 15, 2010 (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 December 15, 2010 by newbtophpautoit Link to comment Share on other sites More sharing options...
Developers Jos Posted December 15, 2010 Developers Share Posted December 15, 2010 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 More sharing options...
newbtophpautoit Posted December 15, 2010 Author Share Posted December 15, 2010 (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.JosJos thanks for the swift response 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 December 15, 2010 by newbtophpautoit Link to comment Share on other sites More sharing options...
newbtophpautoit Posted December 15, 2010 Author Share Posted December 15, 2010 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? :/ Link to comment Share on other sites More sharing options...
Developers Jos Posted December 15, 2010 Developers Share Posted December 15, 2010 (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 December 15, 2010 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 More sharing options...
newbtophpautoit Posted December 15, 2010 Author Share Posted December 15, 2010 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 More sharing options...
Developers Jos Posted December 15, 2010 Developers Share Posted December 15, 2010 (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 December 15, 2010 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now