Macro error message in Agent -- how do dismiss?

When Agent displays a macro error, and the ERR message flashes on the LED display, I know I can clear the error with the clearStatus macro (which I have bound to a key). However, the error message in Agent does not go away.

image

I seem to remember that previously, when you cleared the error using clearStatus, then the message would also disappear from Agent. But now it no longer does.

How do I clear the error in Agent? I feel there should be a Dismiss button, or something like that…

I feel there should be a Dismiss button, or something like that…

I second this.

Allow dismissing the macro error pane. · Issue #2338 · UltimateHackingKeyboard/agent · GitHub

@maexxx How about fixing the issue’s root cause instead, which is, if I’m not mistaken, your macro, which triggers the error?

I may be missing something. Feel free to elaborate.

The macro is mostly fine. The variable has just been used before it was first defined/assigned. Actually, this should be a warning at worst.

For me the usecase is that I am often running into macro errors due to switching branches. The macros are fine, I am just using a firmware branch that doesn’t support them…

Which actually brings me to a different request: how can I check whether a variable has been defined?

I have some forks that may start before another assignment has been made, but I want to avoid having to initialize everything in $onInit as that’s not very modular. Ideally I can keep code for a specific functionality together in a few macros that all start with the same name (kind of like a library or a name space).

It’s a timing between forks in my macros that’s hard to resolve. Now I just want to do more editing in Agent, but the pane just keeps sitting there and annoying me. I’ve acknowledged the error and cleared it with clearStatus but the Agent message just lingers on.

Agent used to clear the message when it was cleared in the keyboard.

Alternatively, how about the firmware executing all $onInitXXX macros on startup? (Any macro with a name starting with $onInit will be executed.) With a macro package, you could drop in it’s initialisation macro too, without having to modify the one single $onInit.

But… then you also need a “safe mode” where no init macros are executed on power on. Maybe by holding a specific key during startup.

How did I come up with all of this? Well, I am almost ready to release a set of macros that implement a much more sophisticated handling of home-row mods. This will require about 12-15 macros all working together, including a timer fork that runs in the background. It either needs some initialisation (“please put the following lines in your $onInit”), or it’s own init macro, or a way to check whether some variables have been defined yet (to know whether it’s been initialised yet).

Which actually brings me to a different request: how can I check whether a variable has been defined?

You can’t.

I have some forks that may start before another assignment has been made, but I want to avoid having to initialize everything in $onInit as that’s not very modular.

Actually I think I will change the implementation slightly in a way that effectively removes the error.

How did I come up with all of this? Well, I am almost ready to release a set of macros that implement a much more sophisticated handling of home-row mods. This will require about 12-15 macros all working together, including a timer fork that runs in the background. It either needs some initialisation (“please put the following lines in your $onInit”), or it’s own init macro, or a way to check whether some variables have been defined yet (to know whether it’s been initialised yet).

You really should start digging into the C code. This is not something the macro engine was designed for.

Alternatively, how about the firmware executing all $onInitXXX macros on startup?

Nah, I am lazy and don’t think this to be a justified request.

You can just call $onInitXXX from your $onInit.

@maexxx Provide me with a macro that doesn’t make Agent trigger an error when saving the configuration but only when executing the macro.

run_once:

if ($has_run == 0) {
    setVar has_run 1
    setLedTxt 999 '1ST'
}
else {
    setLedTxt 999 '2+'
}

Map to a key. Save. No error. Press the key. ERR.

Maybe I should. At the moment I feel it is easier to experiment with different ways of handling home-row mods using macros. Faster to prototype some ideas.

Eventually once the ideas have stabilised, I agree it should be put into firmware.

One more thing: it seems that when a new configuration is saved to the UHK from Agent, the macros currently running will not be stopped automatically. At least not immediately. But the variables get undefined. Often, when I save a new configuration while a background fork is still running and working with variables, all of a sudden it throws an ERR about an undefined variable. But if I save the exact same config again to the keyboard, everything is fine. It seems there is an intermediate state where old scripts are still running but the variables have been reset. Can that be true? If yes, I consider this a bug.

Yes, I think it may be true (not sure though), and in that case I think I call it a bug too.