Sign in to follow this  
Followers 0
dadabre3232

reading data from array

11 posts in this topic

so i have this weird error , im pretty sure it used to work before

lets say i got an array $array[10][10]

i have every array define $array[1][0] = "blabla"

now the issue is this ; when i just use msgbox(0,"",$array[1][0]) its fine it returns the array

but when i use it in function 

func blabla()

      msgbox(0,"",$array[1][0]) - i get blank message

endfunc

Can anyone help me please?

      

 

Share this post


Link to post
Share on other sites



double post accident

Share this post


Link to post
Share on other sites

I suspect it has to do with the scope in which the array is/was defined.  Where in the script are you creating the array, because in your simple example above it is not defined which means it would have to be scoped globally for the function to know about it.

Can you post more code?

Share this post


Link to post
Share on other sites

array is defined as global before using , maybe thats the issue ?

i have global  $array[10][10] at start

Share this post


Link to post
Share on other sites

and to make stuff more intereseting same script , copy pasted into brand new autoit file ... works

Share this post


Link to post
Share on other sites
32 minutes ago, dadabre3232 said:

array is defined as global before using , maybe thats the issue ?

nope.  You need to make the array available/accessible within the function somehow, either by declaring it in the global scope or sending it to the function as a parameter.

 

14 minutes ago, dadabre3232 said:

pasted into brand new autoit file ... works

hmm, odd.

Share this post


Link to post
Share on other sites

it works in some funcs in some it doesnt weird , i have a function that compares inputs with the predefined ini file, works outside func, inside doesnt 

global $list[5][3]

$list[1][1] = iniread...

msgbox(0,"",$list[1][1]) - works here

$list[1][2]=guiread....

func compare($i)

     msgbox(0,"",$list[1][1]) - empty here
     if $list[$i][1] = ""  or  $list[$i][2] = "" then Return
     if $list[$i][1] <> $list[$i][2] Then
          msgbox(0,"","different")
      EndIf
EndFunc

for $i = 1 to 5

     compare($i)

next

scripts returns everytime cause somehow list is empty inside the func and fine outside...

 

Share this post


Link to post
Share on other sites

the thing is , whatever value i add to the  variable , it works only inside the function  that did that , it like resets right after function passess

Share this post


Link to post
Share on other sites

Try putting the For...Next within the function.

Share this post


Link to post
Share on other sites

I understand what your thing is, but I can say with almost 100% certainty that you script is much more complicated with more stuff going on.

Create a simple minimal script which reproduces your issue, along with a temp ini file.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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