and it is to do with the difference between local and global variables as you suspected. Coincidentally I just wrote a post about that which you can find here: Get Mouse Position, Run Other Actions, Then Return Mouse Pointer to Same Position - #25 by tiffle which I recommend you read, but the definitive text about variables can of course be found in the KM wiki (aka user manual). Have a look here manual:Variables [Keyboard Maestro Wiki] and specifically in the section titles “Scope”.
Your use of subroutines is the best way of achieving what you’re trying to do, but because my macro uses the local variable Local__LineFromFile its value will only be available inside my macro and not in any other macro, subroutine or submacro. To get round this you need to supply your subroutine with an input parameter that is my local variable. I’m afraid I’m away from my Mac so I can’t show you the approach explicitly and instead I’ll try to describe it: at the top of your subroutine where it says “Executed as a subroutine with parameters” click the little green + button and fill in the field that appears with the name of the local variable Local__LineFromFile . Literally just that.
Then, in the main macro (that’s the one I provided and modified by you) you’ll see a new field has appeared into which you’ll need to literally type this: %Variable%Local__LineFromFile%. Do that for each of the calls to the subroutine.
By doing this you’re effectively passing the value of the local variable “into” the subroutine where it can then be used in your Open URL action.
If you’ve followed these instructions (literally) everything should now work as intended plus you’d have gotten a slightly better understanding of KM variables and subroutines. If it doesn’t work then I won’t now be around until next week ![]()