MS Help states that "All variables have global scope (are available to the entire script once created)."
Does this include macros that are called (Macro>C:\MacroName.scp) from within the main script?
If not what is the best way to include them in the called macro?
Variable Scope
Moderators: JRL, Dorian (MJT support)
-
- Pro Scripter
- Posts: 132
- Joined: Mon Dec 22, 2008 4:56 pm
- Location: St Augustine FL
Variable Scope
Thank you in advance for all your help
Gil
Gil
-
- Pro Scripter
- Posts: 132
- Joined: Mon Dec 22, 2008 4:56 pm
- Location: St Augustine FL
Re: Variable Scope
I dug a little further and found my answer
Sorry I posted a little to soon.
Gil
Sorry I posted a little to soon.
Gil
Thank you in advance for all your help
Gil
Gil
Re: Variable Scope
Mind sharing your answer in case someone else wants to know?
-
- Pro Scripter
- Posts: 132
- Joined: Mon Dec 22, 2008 4:56 pm
- Location: St Augustine FL
Re: Variable Scope
Just so happens i found the answer in the MS Manual
A word or two should be said about other scripts called or included by your script.
If the Macro command executes another macro. That macro is kept separate from the calling macro. In this instance variables are not shared, so scope could be said to be local. Using the Macro command is like calling a separate process via the command line. Variables can be passed into the called macro via command line parameters, but script variables within the code are not shared. In contrast the Include statement, rather than "call" the included macro file, literally includes the code from that file within the main script. Include is rather like copying and pasting the code from the Include file into the main script file at run time. Therefore in this instance variables are shared as the Included script becomes part of the main script.
Hope this helps
Gil
A word or two should be said about other scripts called or included by your script.
If the Macro command executes another macro. That macro is kept separate from the calling macro. In this instance variables are not shared, so scope could be said to be local. Using the Macro command is like calling a separate process via the command line. Variables can be passed into the called macro via command line parameters, but script variables within the code are not shared. In contrast the Include statement, rather than "call" the included macro file, literally includes the code from that file within the main script. Include is rather like copying and pasting the code from the Include file into the main script file at run time. Therefore in this instance variables are shared as the Included script becomes part of the main script.
Hope this helps
Gil
Thank you in advance for all your help
Gil
Gil