WARNING! Don't use %AccessedVariables% to Clean Up Variables

NOTE: I've re-worded this post.

If you're a KM v10 user, and you're using %AccessedVariables% as a method to clean up global variables at the end of a macro, as shown in KM 10 - Easy Global Variable Clean-Up, it is recommend that you stop doing that, because you run the risk of deleting ALL your global variables.

First, under some circumstances*, %AccessedVariables% can return ALL KM variables, not just the variables you've accessed in your macro. Hence the possibility of deleting all your global variables.

Second, Peter recommends against it, and he's the Architect. We should listen to him.

*Details

As of the time of this writing, if you run a Custom HTML Prompt in your macro, then after it runs, %AccessedVariables% will return ALL your KM global variables.

2 Likes

Can confirm... I nuked almost all of my variables today. (You're welcome KM forum for being the guinea pig here :laughing:)

It. Sucked. Big. Time.

I wonder if this topic can be stickied for the near future?

2 Likes

This is not really a sensible use for the AccessedVariables token in any event.

Who knows what reason you might want to access a variable, and just accessing a variable does not really make it a good candidate for deletion.

Better is to make appropriate use of instance and local variables, and only make exceptions and explicitly empty them if necessary.

1 Like

I happen to agree with you. I'm not sure why you un-pinned the warning - it's still an important warning because the fact is that there are people currently doing this, and they need to stop. And people thinking about doing this should be warned not to do it.

I reworded the warning and re-pinned the post. If you still think it shouldn't be pinned, well, it's your forum, so if you un-pin it again, I won't re-pin it. But I hope you understand that I'm just trying to protect people from losing important data.

I do not think it needs to be pinned globally. It just needs a warning on any topic that is implying this is a good idea.

It is not something most people will ever do or even think about doing, so pinning it globally is too much attention.

OK. And sorry if I caused you frustration or anything with re-pinning it. I didn't know you were still up, an I didn't want to take any chances until you got a chance to weigh in.

I know you know my intentions were good, but still, you've got enough to worry about without me adding to your blood-pressure, so like I said: sorry. :neutral_face:

3 Likes

No worries at all. I appreciate your efforts, and yes, I don’t want folks deleting all their variables, so it is just a minor difference of opinion on how “in your face” the warning needs to be.

Occasionally people make my blood pressure go up, but I don’t think you’ve ever been one of them!

It’s all good, thanks!

If you see any topics advocating using the AccessedVariables token to delete variables, add a warning there. I've added a note to the wiki page as well to clarify its intended use.

2 Likes