LOCALVARS itself should not be global

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
pneves
Newbie
Posts: 19
Joined: Mon Jan 25, 2010 10:59 am

LOCALVARS itself should not be global

Post by pneves » Mon Feb 03, 2014 1:41 pm

Hi ,

I was trying to use LOCALVARS, but when you have more than 1 level it's a nightmare.
Because 1 SUB can alter the LOCALVARS value for all SUBs.
See example bellow.

It would be nice to :
  • -LOCALVARS to be set locally or user another keyword LOCALVARSLOC
    That way it would not affect the value of LOCALVARS in the sublevels
  • -or be able to create/access LOCAL and other levels variables using:
    LetLevelVar>t=1,Level (Level=LOCAL;ABOVE,0)
    GetLevelVar>%var1%,Level,result (Level=LOCAL;ABOVE,0)

Code: Select all

SRT>sub2
   Let>LOCALVARS=1
   Let>a=4

   Let>LOCALVARS=0
   Let>ret=TRUE
END>sub2

SRT>sub1
   Let>LOCALVARS=1

   Let>a=2
   gosub>sub2
   Let>a=3
   MessageModal> a: %a%  ' prints 2

   Let>LOCALVARS=0
   Let>ret=FALSE
END>sub1


Let>a=1
Let>ret=TRUE
gosub>sub1
MessageModal> a: %a%   ' prints 3


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

Post by Marcus Tettmar » Mon Feb 03, 2014 4:00 pm

Thanks for the suggestion. We'll definitely consider it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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