Accessed Variable Checker

Save this action group as a favourite and use it when you'd like to check the value of multiple variables in a macro.

Variable Checker.kmactions (24.4 KB)

Usage:

  • Insert the group at the end of your macro, or wherever you'd like the final variable check to be.
  • If you'd like to see the value of each variable at various stages during the progression of the macro, copy the orange action to those places.
  • Run the macro and you'll see a variable report like this:

Additional features:

  • Variables that have changed from one checkpoint to the next are indicated by an orange left border.
  • You can hide empty variables with the button at the top-left.
  • You can use the search field to refine the displayed variables and values.
  • Clicking a variable name or value will copy it to the clipboard
7 Likes

Love this, @noisneil. The change bars are brilliant.

Thanks so much for sharing!

BTW, did you consider implementing this as a submacro or subroutine? If this were to work, then a caller action could be added to the action favorites.


Not that you asked for suggestions, but I'd find these options to be helpful:

  • local_IncludePattern local_IncludePatterns: regex defining accessed variable to be included
  • local_ExcludePattern local_ExcludePatterns: regex defining accessed variables (or variables matching local_IncludePattern local_IncludePatterns) to be excluded

For complex macros that contain many variables, this would be especially helpful.

1 Like

I did, but there are so few actions involved that I thought that users who don't understand how subs work might find this less intimidating. Download one thing... done. Maybe I was worrying over nothing, but I don't really see much benefit to it being implemented as a sub, particularly when the actions will be removed or disabled after testing.

Could you give me a use-case so I can get my head around what you're after? It sounds like the Search feature might cover the practical applications of trying to refine by variable names or values...?

1 Like

I see your point. Likely prudent for most use cases.

Also, after thinking about this some more, I remember that when I was creating a macro with some overlapping features, I ran into an issue: if only passing %AccessedVariables% to the submacro, it's not trivial to retrieve the caller's variable values.

With that said, Variable Inspector Prompt and Dictionary Editor (by @DanThomas) includes this necessary logic.


The goal would be to limit the number of reported variables, i.e., report a subset of %AccessedVariables% (applying the two regex's to the variable names).

I have some complex macros with tens of variables. When debugging, I'm often only interested in a few.

No offense if you don't want to complicate your simple, yet elegant, approach.

1 Like

I think the term "regex" is throwing me off, as it's not the only way to do things. Am I right in saying that you'd like to limit the displayed variabled by matching strings, before they're displayed rather than after (with the Search field)?

Or have I got the wrong end of the stick?

1 Like

I really need to do video explaining VIP - Variable Inspector Prompt. People have no idea how easy it is to use. Sigh.

2 Likes

Hi, @DanThomas. I use and appreciate VIP - Variable Inspector Prompt often. (Yes, I've specified one or more variables to limit its scope.) Thank you!

Yes, if you shared a video (which are always done well), it would no doubt increase its usage.

With that said, other tools, like what @noisneil has shared here, sometimes fit like a glove.


While we are at it, I'd like to mention Checkpoint System: An Additional Way to Debug in KM by @tiffle.

1 Like

Yes.

Sorry, I'm not being clear.

With VIP - Variable Inspector Prompt (by @DanThomas), one can limit the scope by specifying individual variable names. You could do the same with regex patterns and in some cases it would make specification even easier.

For example, if your macro included the following six variables (among many more):

local_Dialog
local_DialogWidth
local_DialogHeight
local_Window
local_WindowWidth
local_WindowHeight

For local_IncludePatterns, one could specify:

local_Dialog.*
local_Window.*

Ok I think I understand now. That may be a bit antithetical to the lightweight nature of this particular method, which is meant to be as simple as possible in terms of initial set up. Drop it in and you're good to go.

1 Like

@_jims found a couple of parsing oversights and graciously corrected them on my behalf.

Original post updated.

2 Likes