I am looking for article about the difference between subroutine and execute a macro. This article talks a lot about async and sync. since I'm not a programmer, I don't know much about this. but luckily I almost never enable async in my kmm.
At the beginning, I don't use subroutines until I see the convenient of passing variable value in and out of subroutines (even only can pass one var out). I start a big project.
The macros can be called by other macros in my KM all has a prefix in macro name - handler. this word is from AppleScript. I'm not sure if I use this word in correct way, but I really have many hundreds of handler macro in my KM.
I begin doing this handler-sub-conversion. Convert a handler to sub – then use a macro find on this forum – find macros that use selected sub-macro – to find all callers and then go into each of them to change execute a macro to execute sub.
So my question is:
If I don't use async, and don't use input parameter & return from subroutine, and use instance__ and global variables to pass variable value in & out,
Execute a macro
&
Execute subroutine
Are they completely all the same to each other?
If the subroutine need to pass many variables in & out, I choose to keep using the old method - instance__ & global var, but I just find that did this to some macros will lead to some error. The macro doesn't work like before.
I want to post this macro here. but it's too complex and involve a lot of find image on screen. I think it's not easy to replicate the issue on my system. so I ask about this in theory firstly.
Make an example.
here is an simple macro to plus two var value.
And now I convert it to a sub:
But note that, I still use Instance__ to pass var In & Out.
Now In Macro A I call the handler;
And in Macro B I call the sub:
NOTE that in A & B,
all the same except
Handler becomes subroutine
Execute a macro becomes execute sub
So My question: can I have same result in both macros?
For these two macros, YES.
But does this works to all the cases all the time??
call the sub and call the macro - all they same.kmmacros (13.3 KB)