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 

Read .ini backwards

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Mon Apr 12, 2004 6:23 pm    Post subject: Read .ini backwards Reply with quote

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%)
        }       
}

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions 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