Sign in to follow this  
Followers 0
yucatan

iniread

14 posts in this topic

hi i have a .ini file it look like this

[user]

yucatan=matrix

henk=omfg

i wanne make a func that when the func read it like this

[user]

yucatan=matrix

henk=omfg

becomes

yucatan

henk

and i wanne put it in a array

that $array[1] = yucatan

and $array[2] = henk

how i can do that ?

Share this post


Link to post
Share on other sites



hi i have a .ini file it look like this

[user]

yucatan=matrix

henk=omfg

i wanne make a func that when the func read it like this

[user]

yucatan=matrix

henk=omfg

becomes

yucatan

henk

and i wanne put it in a array

that $array[1] = yucatan

and $array[2] = henk

how i can do that ?

You can use Ini functions and StringInStr to know where is char "=" and than StringLeft.

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Autoit has a function to do what you want, look into IniReadSection.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$var = IniReadSection("C:\Temp\users.ini", "user")

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])

Next

EndIf

this code i have now but i cant figure it out.

i needs to read all keys how i do that ?

Edited by yucatan

Share this post


Link to post
Share on other sites

Could you please clarify? I don't understand what you're trying to do. The example given should help you.

Share this post


Link to post
Share on other sites

Could you please clarify? I don't understand what you're trying to do. The example given should help you.

$var = IniReadSection("C:\Temp\users.ini", "user")

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])

Next

EndIf

this code i have now i get 2 times a msgbox with my users

but i want one $var that = both usernames

Share this post


Link to post
Share on other sites

This will place all the usernames in the string $data, seperating them by a space. I'm a little puzzled about you not figuring this out.

$data = ""

$var = IniReadSection("C:\Temp\users.ini", "user")

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 1 To $var[0][0]

$data &= $var[$i][0] & " "

Next

EndIf

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

This will place all the usernames in the string $data, seperating them by a space. I'm a little puzzled about you not figuring this out.

$data = ""

$var = IniReadSection("C:\Temp\users.ini", "user")

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 1 To $var[0][0]

$data &= $var[$i][0] & " "

Next

EndIf

$data = now yucatan admin

i want that $data = yucatan

admin

below eatchother

i got it

$data = ""

$var = IniReadSection("C:\Temp\users.ini", "user")

If @error Then

MsgBox(4096, "", "Error occurred, probably no INI file.")

Else

For $i = 1 To $var[0][0]

$data &= $var[$i][0]&@CRLF & ""

Next

EndIf

MsgBox(4096, "", $data)

Edited by yucatan

Share this post


Link to post
Share on other sites

Replace the space by @CRLF...

Share this post


Link to post
Share on other sites

Replace the space by @CRLF...

how do i check if a var contains a | at the end of the var if | = at the end then delete the | how do i do that

Share this post


Link to post
Share on other sites

If StringRight($string, 1) = "|" Then $string = StringTrimRight($string, 1)

Share this post


Link to post
Share on other sites

If StringRight($string, 1) = "|" Then $string = StringTrimRight($string, 1)

i wanne read a $var out another func how i can do that ?

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Could you be more specific? What function, what variable?

Edited by TomZ

Share this post


Link to post
Share on other sites

Everything you are asking here is in the helpfiles, maybe you could take to effort to try and search them for yourself before asking them here...

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