Sign in to follow this  
Followers 0
TK_Incorperate

IniWrite for other formats?

5 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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 :lmao:

LD

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

patterns.... life's about patterns :lmao:

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 by LondonNDIB

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