Sign in to follow this  
Followers 0
Swiftcuda

Wrong values returned to Array from Iniread

5 posts in this topic

Ok I have an ini file with mouse coordinates. I want to feed those coordinates to a MouseMove command however after StringSplit the results are not what I got from ini file. What am I doing wrong?

$menu=iniread("config.ini","coords","menu","0,0")  

msgbox(0,"title",$menu) ;returns correct value 
global $menu = Stringsplit($menu,",") 
MsgBox(0, "Mouse x,y:", $menu[0] & "," & $menu[1] ) ;returns wrong values

this is from INI file

[coords]  
menu=152,75

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your StringSplit was wrong. To get an zero based array, you need flag=2. :D

global $menu = Stringsplit($menu, ',', 2)
Edited by BugFix

Best Regards BugFix  

Share this post


Link to post
Share on other sites

Your StringSplit was wrong. To get an zero based array, you need flag=2. :D

global $menu = Stringsplit($menu, ',', 2)

With your change I get this result

testarray.au3 (7) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

Share this post


Link to post
Share on other sites

Might want to look at what and how StringSplit() works, in the first example, [0] equals the total number of array indexes.

Global $s_menu=iniread("config.ini","coords","menu","0,0")  

msgbox(0,"title",$s_menu) ;returns correct value 
global $a_menu = Stringsplit($s_menu,",") 
If $a_menu[0] <> 2 Then
    MsgBox(16 + 262144, "Error", "Index count is wrong!")
    Exit
EndIf
MsgBox(0, "Mouse x,y:", $a_menu[1] & "," & $a_menu[2] ) ;returns wrong values

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Might want to look at what and how StringSplit() works, in the first example, [0] equals the total number of array indexes.

Global $s_menu=iniread("config.ini","coords","menu","0,0")  

msgbox(0,"title",$s_menu) ;returns correct value 
global $a_menu = Stringsplit($s_menu,",") 
If $a_menu[0] <> 2 Then
    MsgBox(16 + 262144, "Error", "Index count is wrong!")
    Exit
EndIf
MsgBox(0, "Mouse x,y:", $a_menu[1] & "," & $a_menu[2] ) ;returns wrong values

Thanks that worked beautifully!

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