| View previous topic :: View next topic |
| Author |
Message |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Tue Mar 08, 2005 2:20 am Post subject: IniWrite; No Section |
|
|
I'm wanting to change a value in an ini file made by another program but the respective key isn't under any section (there are no sections at all). Is there anyway to go about this? _________________
 |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Tue Mar 08, 2005 3:04 am Post subject: |
|
|
AHK can currently only read standard INI files. Standard INI files have sections for all the keys. When they don't, it's usually a result of poor designing on the developer's part, as in the case of Microsoft Word (it's INIs do the same thing).  |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Tue Mar 08, 2005 5:14 am Post subject: |
|
|
Why not LoopRead through the file and replace the value? _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5390 Location: /b/
|
Posted: Tue Mar 08, 2005 9:42 am Post subject: |
|
|
| toralf wrote: | | Why not LoopRead through the file and replace the value? | I don't know what the value is; it changes length so standard iniwrite replacement seems the best way. _________________
 |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Mar 08, 2005 10:25 am Post subject: |
|
|
You don't have to care about that !
INI standard: Key=Value ---> Field1=Field2
| Code: | Loop, Read, My.INI, My.INI.tmp
{
StringSplit, Field, A_LoopReadLine, =
If Field1 = MyFavouriteKey
StringReplace, Field2, Field2, %Field2%, MyNewKeyVar
FileAppend, %Field1%=%Field2%`n
}
; FileMove, My.INI.tmp, My.INI, 1 ; Replace edited INI |
Untested.  |
|
| Back to top |
|
 |
|