Jump to content

Unknow error [SOLVED]


Go to solution Solved by FireFox,

Recommended Posts

I've noticed a strange phenomenon, namely the script loops indefinitely when I use "Array" word in the string.

Try this:

#include <Array.au3>

Global $aStrings = StringSplit("Apple,Orange,Array,Milk", ",")
_ArrayDisplay($aStrings)
For $array = 1 To $aStrings[0]
    MsgBox(32, "", $aStrings[$array])
    Assign($aStrings[$array], $aStrings[$array], 2)
Next

It never ends, right?

Now try another one. Just change "Array" to "Cola" for example. It should works fine.

I'm not sure, is it a bug? 

Edited by Shanheavel
Link to comment
Share on other sites

  • Solution

Hi,

"Array" corresponds to your variable $array when it's assignated (autoit is case-insensitive).

Thus you change the $array value and the loop never ends.

Edit: Not tested, it's a suggestion and I may be wrong...

Edit: Yeah, the $array var changes to "Array" (interpreted as 0 for a variable type number).

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Hi,

"Array" corresponds to your variable $array when it's assignated (autoit is case-insensitive).

Thus you change the $array value and the loop never ends.

Edit: Not tested, it's a suggestion and I may be wrong...

Edit: Yeah, the $array var changes to "Array".

Br, FireFox.

 

Yea, now it makes sense. 

However $array in loop is local and "Array" is global variable... but okay.

Thanks for fast reply. I think that thread is closed. 

Link to comment
Share on other sites

Yea, now it makes sense. 

However $array in loop is local and "Array" is global variable... but okay.

You change the $array variable in the loop so it's the same scope.

And $array is declared in the global scope here, if your code is not inside a function.

Edited by FireFox
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

×
×
  • Create New...