Jump to content

IniWrite for other formats?

Recommended Posts

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....


and his is more like this....

// 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 [].


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


Link to post
Share on other sites

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:




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

; 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.


ps. Sorry, was going to give you a more complete answer but got called away. Good luck.

Edited by LondonNDIB
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...