Some Macros Might Have Some Variables That You'd Like to Use in Another Macro

Lets say I have a parent macro that has two child Execute Macros and I'd like to use the variables that were inside the first child Macro to be brought into the second child macro.

It's difficult cos there is no way of knowing what variables are accessible. Is it possible to create a flag or tag which variables are accessible so that Execute Macro perhaps give us more info.


Execute Macro: Child Macro 1
Exported variables: num_of_dogs

So I see it and go "ok I got access to num_of_dogs and I can now use that in Child Macro 2.

Perhaps I don't understand your question.

All variables (unless they start with "Local" or "Instance") are global and therefore can be accessed inside any macro, even macros that are run asynchronously.

There is no reasons to export anything because they are all visible everywhere. You don't need to "bring them into" the other macro because they are already visible to the other macro.

Yes how do you know which ones are accessible?

So we take the above scenario that I mentioned earlier. Lets say I thought I made a variable called "Power" inside First Child and then I want to use it in second child but when I display that the contents of that variable nothing appears.

I'm like "huh, oh that's because I didn't create "Power". Well if I had of known that it was not available inside the first child, I wouldn't have try to access it"

I realise that I could manually open it but if it's large, it might take a while to find where that variable is.

It would have been faster to know that it is accessible in the first place.

I’m not certain I follow you but there are three kinds of variables:

  1. Global, which are available to any macro, any time.
  2. Instance, which are available to the macro they were created in as well as any subroutines.
  3. Local, which are available only within the macro they were created in.

So if you want a variable to be available in the original (calling) macro as well as any subroutines, use a global or instance variable.

You both are assuming your variable has been set.

I'm talking about whether you don't know whether you have set it or not.

Ahh, well in that case it's not a variable. A variable that doesn't exist doesn't exist. How do you expect to access a variable in macro B if it hasn't been created in Macro A?

Maybe you didn't know about this expression:

This is why if you knew it existed, you would use it in the second child.

Let's say you go away for a week and you now you wanna continue on with the second child. Is it absolutely necessary to open up the previous child to see which variables are accessible?

Why not just show it on the execute macro at the bottom?

I'm really talking about workflow here and speeding it up. Mine must be terrible.

Show me your code and I will fix it. I'm having trouble understanding what you want. I showed you above how to detect if a variable exists.

I don't know what you want when you say "Why not just show it on the execute macro at the bottom?"

Your request is not unreasonable, except for the fact that it would potentially be quite a mission to add in to the editor.

In the meantime, you can use Subroutines. They will do something close enough to what you're looking for.

Just Google Keyboard Maestro Subroutine.

I'll let you handle it from here since you understand his request.