ozbob Posted January 20, 2005 Share Posted January 20, 2005 I would like to read all the keys and values from one particular INI Section. With the option INIREAD I cannot see how to do this since you need to specify the key within the section. But I don't know the key so I want to read the entire SECTION without specifying the key(s). Link to comment Share on other sites More sharing options...
DirtyBanditos Posted January 20, 2005 Share Posted January 20, 2005 I would like to read all the keys and values from one particular INI Section. With the option INIREAD I cannot see how to do this since you need to specify the key within the section.But I don't know the key so I want to read the entire SECTION without specifying the key(s).<{POST_SNAPBACK}>Hello look on the Autoit Helpfiles ! $sFile=@SCRIPTDIR & '\Test.ini' $spam6=IniRead($sFile, 'spam', 'spam', 'Read this ini') $spam=InputBox("DirtyBanditos", "Please enter your Message", $spam6) iniwrite($sFile, 'spam', 'spam', $spam) Link to comment Share on other sites More sharing options...
ozbob Posted January 20, 2005 Author Share Posted January 20, 2005 $spam6=IniRead($sFile, 'spam', 'spam', 'Read this ini') In this line you specify SPAM twice: 1. For the section 2. For the key My problem is that I know which SECTION to read but I do NOT know the KEY name.....I want to know which keys there are and how many. Any suggestions..... Link to comment Share on other sites More sharing options...
Domonoky Posted January 20, 2005 Share Posted January 20, 2005 Hi .. i think the easyst thing would be, not to use the inread function. :-) If you read it as a normal file, an parse it line by line.. i think it would be easy :-) so look in the helpfile about filereadline funktion.. mfg Domonoky Link to comment Share on other sites More sharing options...
Lazycat Posted January 20, 2005 Share Posted January 20, 2005 I'm not remember, maybe someone made and posted similar UDF. Here is my variant: Dim $str = "" $a = _IniEnumKeys("wincmd.ini", "left") For $i = 1 to $a[0] $str = $str & $a[$i] & @CR Next MsgBox (0, "Num keys=" & $a[0], $str) Func _IniEnumKeys($sIni, $sSection) Local $aKeys[1], $iKeyCnt = 1 $aKeys[0] = 0 $hIniFile = FileOpen($sIni, 0) While 1 $sLine = FileReadLine($hIniFile) If @error = -1 Then FileClose($hIniFile) Return $aKeys Endif If StringInStr($sLine, "[" & $sSection & "]") Then Exitloop Wend While 1 $sLine = FileReadLine($hIniFile) If @error = -1 Then Exitloop $sLine = StringStripWS($sLine, 3) If StringLeft($sLine, 1) == "[" and StringRight($sLine, 1) == "]" Then Exitloop $iEqPos = StringInStr($sLine, "=") If $iEqPos and not (StringLeft($sLine, 1) == ";") Then $iKeyCnt = $iKeyCnt + 1 ReDim $aKeys[$iKeyCnt] $aKeys[$iKeyCnt-1] = StringLeft($sLine, $iEqPos-1) Endif Wend FileClose($hIniFile) $aKeys[0] = $iKeyCnt - 1 Return $aKeys EndFunc Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Valik Posted January 20, 2005 Share Posted January 20, 2005 Weird, I remember reading this thread, but it had no bearing what-so-ever on my post I made in the developer's private forum. There's an API call to get this information, it just hasn't been added to AutoIt yet. After the next stable release (103), I'll submit something to Jon for the new beta's that will do this. And before anybody asks, the function isn't useable with DllCall(), it uses double-NULL terminated strings with NULL delimiters. Link to comment Share on other sites More sharing options...
Josbe Posted January 20, 2005 Share Posted January 20, 2005 $a = _IniEnumKeys("wincmd.ini", "left")...the great TCommander! Weird, I remember reading this thread, but it had no bearing what-so-ever on my post I made in the developer's private forum. There's an API call to get this information, it just hasn't been added to AutoIt yet. After the next stable release (103), I'll submit something to Jon for the new beta's that will do this.And before anybody asks, the function isn't useable with DllCall(), it uses double-NULL terminated strings with NULL delimiters.<{POST_SNAPBACK}>By the way, it would be very good. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
ozbob Posted January 21, 2005 Author Share Posted January 21, 2005 Thanx a lot this is exactly what I needed......and it would indeed be great if this could be added as an AUTOIT function. Link to comment Share on other sites More sharing options...
Lazycat Posted January 21, 2005 Share Posted January 21, 2005 After the next stable release (103), I'll submit something to Jon for the new beta's that will do this.Great, this is too essential function (and enumerating sections also)....the great TCommander!Yeah, this is an alpha and omega! Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now