You can be fairly certain that variables declared in the main script as Local (Dim) will not be available in a function. Globals will be..

"If IsDeclared(var)" is usually used in the Main program to declare a var. A common use is when you sometimes pass $VarX on the command line.. it is auto-declared as a Global in that manner. If you don't pass the var but test it, you'll get an Undeclared varname error. Adding the
 Code:
If NotIsDeclared($VarX)Global $VarX EndIf
logic will allow arbitrary passing of that var on the command line without worrying about parsing errors.

It's also commonly used in an initialization function to define global vars only during the first call to the Init function to insure that you don't duplicately define the variables.

Your first example doesn't fit a common method.. Your second example follows the Init methodology.

As Allen suggests - tell us more about what you want to do.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D