Jump to content

Wrong values returned to Array from Iniread


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...