Maestro inconsistent behavior

var dest = ( "%Variable%DND_SaveLocal%/%Variable%TrayFileName%%Variable%Laser%” );
saveFileToPDF("", dest);

So I have a call to some javascript as above. This works occasionally. I have a variable named Laser and Laser1, both with the same data. Eventually have to add Laser2.

Here's the problem, This works and outputs a PDF, but when I change the variable to Laser1, it breaks.
All this is doing is setting a save location and file name so it isn't that complex.

Here's the kicker. I change Laser1 back to Laser variable and it no longer works.

Is there some subsystem that isn't updating correctly? Yes I quit Maestro between attempts and shut down the engine. Why isn't there more consistency in Maestro behavior? I should be able to change something, see the results. If they aren't ok, change back to the way they were and then be able to try something else without the whole macro breaking.

See Accessing Keyboard Maestro Variables in JXA.

Thanks for responding. However I inherited a massive collection of Macros and and just trying to make some minor changes. Overall I think it needs a major overhaul, but right now the most basic stuff is just very unstable.

It is unbelievable that I change one value and that doesn't work or gives undesirable results, then I change it back to exactly how it was before and now it won't work at all. What gives?

Unidentifiable issues can be frustrating! Can you confirm that the macros you inherited worked before making any modifications to them? Because I have found that “inherited” macros, or those I download from the forums sometimes won’t work even before I start tinkering with them due to the variances between different people’s computer environments.

1 Like

Yes, everything worked before and still works. Just seems like I can't plug in variables to where I want them. The variables have the correct values, I should be able to references them wherever I want.

Before rushing to blame KM for being defective, it would be wise to check that the fault is not with the macro, which is a lot more likely. If you post the macro here, someone may well be able to help. See the Forum page of the Wiki for more information on this.

Not necessarily. We can't presume what side-effects may result from executing the macro. It looks as though it is using global variables, for a start. From the Variables page of the Wiki:

Global Variables are permanently stored on your Mac drive (like a file), and are available for read/write in any Macro or Action, not just the Macro where the Variable was created. These variables persist between logins and restarts of your Mac.

I didn't say KM was defective, I imagine the cluster F of almost 500 macros and around 100 JS functions there are just some things not meshing right. This still doesn't explain why I can't try something and if it doesn't work why I can't change things back and it functions differently. The variables I am accessing are static and don't change in this context.

The one line of code you quoted is not correct syntax for accessing a Keyboard Maestro variable. So I pointed you to the reference.

If you can create a small example macro to illustrates the problem, I'm sure someone can explain why it isn't working for you.

Ok here is a video that is about 6 minutes showing the inconsistency.

First off I start with a clean import of the macro set. You will see it works but the PDF in the lower left corner doesn't have a C3 suffix like the DXF files. I go to the DXF export macro and copy the laser variable (C3 is a designation of a laser engraver). Paste it in the PDF export macro and the C3 shows up just fine. Thats great. But I need to make a set of files called C5 in addition to C3, don't ask just what is required by manufacturing. So first I add a 1 to the end of the Laser variable. Laser and Laser 1 are the same, both have C3 populated. Now run the macro again and PDF is gone. Poof. Thats fine probably some Javascript issues. But later in the video you'll see me trying to get back to square one by returning the macro to the initial state. And I can't. That is the inconsistency that is frustrating. The only way I can get back to square one is delete the macro set and reimport.... Not a biggie to do that, but I should be able to move variables around at any time and they turn on and off each time something is changed.

So pretty much the only consistency I can get is to make it fail. I should be able to bring it back to the original state without having to load the macro set again.

So, think I have it resolved. All along, it is SMART QUOTES. They are hard to see on the small display but sure enough replacing them all fixed things.