Jump to content
Sign in to follow this  
dadabre3232

reading data from array

Recommended Posts

dadabre3232

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
dadabre3232

double post accident

Share this post


Link to post
Share on other sites
spudw2k

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
dadabre3232

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
dadabre3232

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
spudw2k
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
dadabre3232

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
JohnOne

Do you get access error?

The problem with pseudo code is that no-one can test it.

If you were to try to create a real script that people could test, I guarantee you will realize you error along the way.


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
dadabre3232

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
KickStarter15

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


Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Share this post


Link to post
Share on other sites
JohnOne

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  

×