Jump to content

Global declared twice, is it suppose to keep the previous value?


 Share

Recommended Posts

I wasn't sure if the interpreter would ignore subsequent Static declarations, as it appears to do under normal circumstances in local scope: when a function is repeatedly called. The fact it throws an error tells us something about the inner workings of AutoIt.

Edited by czardas
Link to comment
Share on other sites

Another question might a;so arise.

We know that in AutoIt you do not have to declare a variable with either the Global or Local scope keywords (excluding uninitiated arrays maybe).

So we say this is bad...

While 3
    Local $var = 10
    ;Something else
    Sleep(1000)
WEnd

But what is happening here...

While 3
    $var = 10
    ;Something else
    Sleep(1000)
WEnd

Is it being re-declared?

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Not the way I see it.

The variable exists after the first encounter and its assigned value is overwritten on subsequent runs. If the variable does not already exist, it will be declared internally within the local (current) scope, which could be either local or global depending on the circumstance.

Edited by czardas
Link to comment
Share on other sites

Depends.  If you declare local on the same level as another local with the same variable name, then they will overwrite.

If you declare local inside a function, and outside a function, they are seperated.

If you declare global outside a function and DONT local the same in a function, the global is overwritten.

If you declare local outside a function and DONT local the same in a function, the outside local is overwritten

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...