Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Mon Apr 12, 2004 6:23 pm Post subject: Read .ini backwards |
|
|
There is an inbuilt function in AHK to read ini file values when Section and Key are given. I've faced a couple of times when I needed the opposite, I had the value and had to know the Section and Key.
This little function gives the following:
section of the value
Key of the value
line no. in .ini file
| Code: | ToFind=SomeValue
IniFile=Inifile.ini
Loop, Read, %IniFile%
{
IfInString, A_LoopReadLine,[
IfInString, A_LoopReadLine,]
SetEnv, Section, %A_LoopReadLine%
StringGetPos, EqPos, A_LoopReadLine, =
StringTrimLeft, Value, A_LoopReadLine, %EqPos%
IfInString, Value, %tofind%
{
StringLeft, Found, A_LoopReadLine, %EqPos%
;Available info:
;%Section% = section of the value
;%ToFind% = value to be found
;%Found% = Key of the value
;%a_index% = line no. in .ini file
Msgbox,0,Found, %Section%`n`n%Found%=%ToFind%`n`n(Line %a_index%)
}
} |
_________________
 |
|