Few Questions on Scope

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
fthomas
Pro Scripter
Posts: 91
Joined: Fri Oct 03, 2008 6:40 pm

Few Questions on Scope

Post by fthomas » Thu Nov 11, 2010 10:33 pm

I'd like to ask a couple of questions.

If I've created a SRT section (subroutine) and I've used a label within it, can I use the same label outside of the subroutine too?

Variables created within a subroutine - are they only within the scope of the subroutine or outside the subroutine too?

Frank

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Nov 12, 2010 9:16 am

By default all variables have global scope. If you want variables within subroutines to have local scope (scope only within that subroutine) then set LOCALVARS to 1.

See the section the help file cunningly titled "Scope":

http://www.mjtnet.com/OnlineHelp/scope.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

fthomas
Pro Scripter
Posts: 91
Joined: Fri Oct 03, 2008 6:40 pm

Post by fthomas » Fri Nov 12, 2010 2:28 pm

Hey Marcus,

I didn't see the article, but I'll look it up now. I'll ask ask, since I'm here, about the use of labels on scope.

Frank

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Nov 12, 2010 3:15 pm

Scope in Macro Scheduler refers only to variables.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

fthomas
Pro Scripter
Posts: 91
Joined: Fri Oct 03, 2008 6:40 pm

Post by fthomas » Fri Nov 12, 2010 4:27 pm

Thanks

Frank

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts