Same here. But I have played around and think I am beginning to see some real world uses for this.
I have an existing Group of Macros that will open Finder Folders. Each Macro has a different Path and calls a Sub Macro to do the actual work of determining if I am in the Finder (opens the Folder in one way) or if I am in a Save As Dialog (opens the Folder in a different way).
I have adapted this to the Subroutine and Parameter approach.
The Subroutine does all the work and its "Parameter" is the file path. This value has been sent to it by the Calling Macro.
The Parameter in the Subroutine has "LOCAL" at the head of its name so that it doesn't persist after the run. And it is referenced just like a Variable in the Submacro (in fact it appears to be a Variable to all intents and purposes).
Interestingly the "LOCAL" part of its name gets stripped off in the Action that calls it.
Parameter is defined like this in the Subroutine:
But is referenced like this in the Caller Macro:
And the Parameter seems to be referenced just like a Variable in the Subroutine itself:
So, I am sure this is not exactly how Subroutines are intended to be used but in this case it allows me to have one Subroutine that does all the work and a whole series of Caller Macros that have just one Action in them - i.e. the Action that calls the Subroutine and has the actual folder path to pass to the Subroutine.
(To try this Example Macro out just change the file path in the Magenta coloured Action to a real folder path on your system.)
EXAMPLE Go To Folder in Finder or Save Dialog Macros.kmmacros (5.9 KB)
The Calling Macro looks like this. This is the Macro where you need to change the File Path to a real one on your System. And you would make copies of this Macro, just with different File Paths:
And the Subroutine Macro looks like this:
I'm sure there are going to be many more sophisticated uses of Subroutines (my example doesn't make any use of sending the results back to the Calling Macro) but for me this is a start of understanding the concepts.
EDIT - Why would I have a Caller Macro and this Subroutine? Why not just have all the workings in the Caller Macro? Because - this way if I discover the Subroutine needs to be adjusted to work well (i.e. a pause time between Actions to be changed) I only need to edit one Macro not all the Caller Macros.
EDIT 2 - Just discovered something really cool. If the Parameter name is changed in the Subroutine it auto-updates in all the Calling Macros. I thought "FolderPath" might be a better name than "FilePath" and as soon as I changed it in the Subroutine all the Calling Macros updated as well:
Changed Parameter name in Subroutine:
All references auto-update in Calling Macros: