A local variable goes out of scope when the block of code it was declared in ends. This can be in several different ways.
Any variable declared in the same line as the start of a complex statement is in scope until the complex statement ends. Any variable declared in the instructions block is in scope until the instructions call ends and returns execution to the complex statement's own code.
for var int i = 3 to 5 ' i is in scope. var s$ = "test" ' This goes out of scope and is redeclared each time through the loop ' Now that the loop has ended, both i and s$ are out of scope.
These statements are really just complex statements. The same rules apply as where given above. In fact, the using keyword exists only to provide such help with scope.
using var i% = 3 ' i% is in scope ' i% is out of scope.
A DASIL global variables is in scope as long as the script file it was declared in is executing. Such variables are visible only to code in that exact same script file.
These never go "out of scope". However, their visibility might change depending on which namespace you try to access them from.
These only go out of scope when the instance of the enclosing type itself goes out of scope.
Wiki: Complex Statements
Wiki: Home
Wiki: keywords-instructions
Wiki: keywords-using