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
Macro A calling Macro B?
Moderators: Dorian (MJT support), JRL
-
- Macro Veteran
- Posts: 267
- Joined: Mon Sep 27, 2010 8:57 pm
- Location: Seattle, WA
There are 2 things I use along this same idea. One is what you were describing, where MACRO_1 calls MACRO_A.
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
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.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?