Variables in nested macro

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
gummybear
Newbie
Posts: 4
Joined: Mon Apr 26, 2010 1:55 pm

Variables in nested macro

Post by gummybear » Mon Apr 26, 2010 2:02 pm

On the recommendation of somebody in some post somewhere in the forums, I have 1 macro that runs every 10 minutes and also schedules other macros when the time is right.

So it's

Code: Select all

scheduler macro:
if time is whatever: run macro 1
if time is whatever: run macro 2
macro 3
macro 4
What I'd like to know is how the variables in the nested macros work. For example, I've found that if I set Let>browser=something in the scheduler macro, I can't use the browser variable in any of the nested macro, it doesn't work.

My macros use a lot of image recognition and if I have a NumFound variable in macro 1, and the same NumFound variable in macro 2, will they be independent variables or will NumFound in macro 1 carry over to macro 2?

Assigning 3 new variables for every image recognition sequence seems very tedious and I was wondering if there was a more efficient way.

Thanks

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Mon Apr 26, 2010 2:39 pm

Hi gummybear,

Each macro has its own variable scope, so nesting is OK.

It is subroutines within a macro that have global scope and you run into the nesting problem you describe.

With Macro Scheduler v12, subroutines with local scope will be possible as well.


Gale

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 Apr 26, 2010 2:54 pm

And if you WANT global scope then consider using Include instead of Macro

Or use Macro and pass parameters into the called script.

See:
http://www.mjtnet.com/blog/2009/09/09/i ... ary-files/
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
cron
Sign up to our newsletter for free automation tips, tricks & discounts