|
Post by slavik73 on Mar 16, 2018 20:05:34 GMT
Hi, I want to split a macro(s) to some sub-modules to create different flows. I mean - have a library of sub-blocks and call them from the main macro(s) when need. Is it possible to do it using "load macro"? Does "load macro" returns back to original macro after finishing?
|
|
|
Post by Steve on Mar 17, 2018 5:28:00 GMT
Hi, Handling for sub-blocks can be done by running the sub-block as a second instance of MMM and waiting for the flow to return to the main loaded macro. Have a look at this example: 1 | RUN ACTION | | | | MESSAGE PROMPT | 1::1 2 | RUN ACTION | | | | MESSAGE PROMPT | 2::2 3 | RUN ACTION | | | | MESSAGE PROMPT | 3::3 4 | RUN ACTION | | | | RUN VIA CMD /C | d:\Macro\minimousemacro.exe /e "d:\macro\sub_1.mmmacro" 5 | RUN ACTION | | | | WAIT SECONDS | 3 6 | IF NOT | WINDOW TITLE | MMM: sub_1.mmmacro | EXIST | CONTINUE 7 | RUN ACTION | | | | MESSAGE PROMPT | 4::4 8 | RUN ACTION | | | | MESSAGE PROMPT | 5::5 9 | RUN ACTION | | | | MESSAGE PROMPT | 6::6 - Line 1,2,3 - The macro prompts 3 times
- Line 4 - The macro runs, via the command prompt, a second instance of minimousemacro.exe that loads my sub-routine file (sub_1.mmmacro) then closes
- Line 5 waits 3 seconds grace for the second instance of the macro to load
- Line 6 waits for the window title of the second instance (MMM: sub_1.mmmacro) to NOT exist before continuing. When the second instance of minimousemacro.exe has closed, then it continues.
- Line 7,8,9 - the macro prompts 3 times
Hope this helps.
Regards, Steve.
Edit - Version 6.7+ makes loading subroutines easier by using FOR EACH LINE IN [macro] RUN: Getting CLIPBOARD to a static variable is not pretty but I have a solution. Create this macro and save it: CLIPBOARD_IN.mmmacro1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::%STRING% 2 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING1%:: | 3 | IF | FILE | D:\Macro\TX\in.mmmacro | EXIST | DELETE FILE | D:\Macro\TX\in.mmmacro 4 | RUN ACTION | | | | OUTPUT TO FILE | D:\Macro\TX\in.mmmacro::APPEND::1%STRING1% RUN ACTION%STRING1% %STRING1% %STRING1% %STRING1% DEFINE STRING VARIABLE%STRING1% 5 | RUN ACTION | | | | OUTPUT TO FILE | D:\Macro\TX\in.mmmacro::APPEND:: %STRING% 6 | RUN ACTION | | | | WAIT SECONDS | 1 7 | RUN ACTION | | | | RUN VIA CMD /C | echo ^:^:%CLIPBOARD%>>d:\macro\tx\in.mmmacro 8 | RUN ACTION | | | | WAIT SECONDS | 1 9 | FOR | EACH | LINE IN | d:\macro\tx\in.mmmacro | RUN 10 | RUN ACTION | | | | MESSAGE PROMPT | Value of STRING: %STRING%::STRING VALUE Line 1 we define STRING to the word '%STRING%' Line 2 we define STRING1 to ' |' (my current delim value is ' | ' however the trailing space is cut by the variable assignment) Line 3 if my input file exists I delete it Line 4 we start to create the file in.mmmacro. Notice the extra space I added after STRING1 for the correct delimiter. Line 5 we add the value of ' %STRING%'. We do this on a new APPEND line. Line 6 wait a second for the output just in case
Line 7 we add the TRUE value of CLIPBOARD to in.mmmacro Line 8 wait a second for the command window just in case Line 9 we run in.mmmacro and add in the TRUE value of %clipboard%
CLIPBOARD_IN.mmmacro can be called from other running macros like this: EXAMPLE.mmmacro1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::Before 2 | RUN ACTION | | | | MESSAGE PROMPT | START:%string%:: 3 | FOR | EACH | LINE IN | D:\Macro\CLIPBOARD_IN.mmmacro | RUN 4 | RUN ACTION | | | | MESSAGE PROMPT | END:%string%:: Hope this helps, Steve.
|
|
|
Post by slavik73 on Mar 17, 2018 11:37:56 GMT
Interesting point. Thanks, I will try this way
|
|