Macro A calling Macro B?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
dheck2
Newbie
Posts: 3
Joined: Thu Jan 06, 2011 5:40 am

Macro A calling Macro B?

Post by dheck2 » Fri Jan 14, 2011 4:11 pm

I would like to create a Driver Macro, that encorporates a number of sub macros. I would like to pass parameter values to a submacro if necessary and return a variable from the sub macro if desired. Is this possible and if so, how. Simple example would be fine. Any parameter passing would also be desirable.

Thx, Dave

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Fri Jan 14, 2011 5:33 pm

There are 2 things I use along this same idea. One is what you were describing, where MACRO_1 calls MACRO_A.

Code: Select all

Let>MACRO_1=%SCRIPT_DIR%\Macro_1.scp
Let>MACRO_A=%SCRIPT_DIR%\Macro_A.scp
   //(Macro_A could be defined in Macro_1)

Macro>MACRO_1 /NEXTMACRO=%MACRO_A% /DATA1=%Some_data% /DATA2=%more_data% 

/////////////////////////////////////////////////////////
In MACRO_1

//Call macro passed in from calling script
MACRO>NEXTMACRO /DATA=%DATA1% /MOREDATA=%DATA2%

But also, you can put multiple subroutines in a macro. I use the 1st passed parameter to identify the subroutine that is called in the first lines of the macro.

Code: Select all

Let>MACRO_1=%SCRIPT_DIR%\Macro_1.scp

Macro>MACRO_1 /SubToRun=%SubRoutine_1% /DATA1=%Some_data% /DATA2=%more_data% 

//////////////////////////////////////////////////////////
In MACRO_1

//Call Subroutine passed in from calling script
GoSub>SubToRun,DATA1,DATA2

SRT>Sub1
End>Sub1

SRT>SubToRun
...
End>SubToRun
etc.
Thanks,
Jerry

[email protected]

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

Post by Marcus Tettmar » Sat Jan 15, 2011 11:04 am

And to return a value back from the sub macro set the MACRO_RESULT variable.
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