Feature Request: "Delete Variables Used in the Macro" Action

One of the most annoying parts (for me) is to add Set variableX to %Delete% at the end of a macro.
It'd be useful to automate this.
How: As an action that I could place at the end of a macro, so it automatically deletes all the variables set in a macro.

@peternlewis

thanks

Hi @hello,
There has been a fair bit of previous discussion surrounding KM variables - particularly about identifying them so that they can be renamed as a "bulk" operation. The conclusion I drew from these discussions is that there are so many ways that variables can be named, created, referenced and used in KM that such a task (just identifying them) would be impossible!

My suggestion to you would be what I now do: wherever possible use Local and Instance variables in your macros as these are automatically deleted when the macro finishes: problem solved!!

Would that work for you?

3 Likes

ah, nice. I've seen some recently uploaded macros using a Local__something nomenclature, so I guess that's the route to go then?

I would say yes to that.

BTW - did you know that setting a variable to %Delete% doesn't actually delete it from the KM system? All it does is stop it appearing in the Variables Inspector. Of course, if a variable had the text of War & Peace stored in it, then it makes a lot of sense to replace that with %Delete% as it takes up much less room.

Here's a peek inside my Keyboard Maestro Variables.sqlite file in the KM Applications Support folder on my Mac:

There are 574 entries in that file of which 472 are marked %Delete%. In other words over 80% of the entries in that file are redundant!

waaiit, what?

*[insert Darth vader meme screaming noo]

... it'll be an "interesting" weekend project to cleanup KM variables...

:rofl:

Don’t mess with KM system files - that could turn “interesting” into “nightmare”.

2 Likes

Hey @hello,

It looks like this will not be done anytime soon.

Highlight Actions, Step-by-Step for Debugging

Local and Instance variables are the simplest way around the problem

Variables user manual section

But that makes debugging your macros more difficult.

-Chris

2 Likes