TK_Incorperate Posted January 19, 2006 Share Posted January 19, 2006 Ok well, I'm making a program to edit a friend's .ini (a different program the the one I'm talking about in the GUI section) and I want to write in his .ini but it isn't setup like the ones autoit uses. I was wondering if there is any way to change the way it writes in the .ini? For example, autoit's .ini would be like this.... [text] text=text and his is more like this.... ///////////////////////////////////////////// // text ///////////////////////////////////////////// text="text" I know that the text after the backslash isn't read, but even still when i use IniWrite and take the text completely out of what would usualy go in the little brackets, it just makes [] and creates a new line, i want it to write where it's already at in the .ini WITHOUT typing []. ~TK Link to comment Share on other sites More sharing options...
LondonNDIB Posted January 19, 2006 Share Posted January 19, 2006 First off... if its an INI file and its in Windows, one might suggest that you stick to the standards of INI formatting and do it the way AutoIt wants to - its not an AutoIT thing... its an INI thing. However, if that just doesn't work for you then just read and write the file like you would any non-ini text file using FileRead, FileReadLine, _FileReadToArray, FileWrite, FileWriteLine, _FileWriteFromArray LD Link to comment Share on other sites More sharing options...
LondonNDIB Posted January 19, 2006 Share Posted January 19, 2006 Sorry... after re-reading your post I see you can't "Stick to the standards of INI formatting" because its an external file beyond your control. Skip to the 2nd paragraph above and ignore the first LD Link to comment Share on other sites More sharing options...
TK_Incorperate Posted January 19, 2006 Author Share Posted January 19, 2006 Well how would i use the FileRead thing to predict where to type what, and to replace text if it was alrady inside the quotation marks? ~TK Link to comment Share on other sites More sharing options...
LondonNDIB Posted January 19, 2006 Share Posted January 19, 2006 (edited) patterns.... life's about patterns I don't know what exactly you are trying to achieve, but using your example above if you wanted to replace the line: text="text" with text="FooBar" You can simply go: $filename = test.ini $i = 1 While 1 $check = FileReadLine ( $filename, $i ) If StringLeft ( $check, 6 ) = "text=" Then ExitLoop; read in the first 6 characters since we are looking for "[tab]text=" $i = $i + 1 Wend ; now we know that the line in question occured at line $i Then re-write the file but at line $i put in the new line. LD ps. Sorry, was going to give you a more complete answer but got called away. Good luck. Edited January 19, 2006 by LondonNDIB 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