AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IniWrite; No Section

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Tue Mar 08, 2005 2:20 am    Post subject: IniWrite; No Section Reply with quote

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
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Tue Mar 08, 2005 3:04 am    Post subject: Reply with quote

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). Very Happy
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Tue Mar 08, 2005 5:14 am    Post subject: Reply with quote

Why not LoopRead through the file and replace the value?
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Tue Mar 08, 2005 9:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
BoBo
Guest





PostPosted: Tue Mar 08, 2005 10:25 am    Post subject: Reply with quote

Quote:
it changes length
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. Cool
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group