Sign in to follow this  
Followers 0
Vladi243

Help with IniReadSection

3 posts in this topic

Hey,

I read in the help file about the function IniReadSection(). I can't understand how it's working.

There is written that the element[n][0] obtains the key and the element[n][1] obtains the value.

I realy don't understand it. I tried to obtain them, but it's not working.

Can someone explain it to me with example?

Thanks.

Share this post


Link to post
Share on other sites



Make sure with IniReadSection() you use a loop, because $element[n] is the counting variable,

And the example in the helpfile looks fine to me...

$var = IniReadSection("C:\Temp\myfile.ini", "section2")
If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $var[0][0]  
        MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
    Next
EndIf

It reads [section2] in the .ini on the first line. then after checking for an error, it starts at 1 and from 1 To $var[0][0] it counts the number of elements returned.

From helpfile: The number of elements returned will be in $result[0][0].

Then in the msgbox() it uses the counting variable $i with either [0] or [1] to show the current key or value.

I hope I was clear enough.

Share this post


Link to post
Share on other sites

Hi.

Edit the sample to point to your ini and the section you want to read.

#include <array.au3>

$YourIni=@WindowsDir & "\system.ini" ; replace 
$YourSection="386enh"                      ; replace

$IniArray=IniReadSection($YourIni,$YourSection)
_ArrayDisplay($IniArray)

regards, rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0