Jump to content

Recommended Posts

Posted

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?

      

 

Posted

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?

Posted
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.

Posted

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...

 

Posted

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.

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
×
×
  • Create New...