Multiple 'If Conditions Met' not working as I expect

Hi there. I've been using KM for over a year now and love it. However, my latest project has me stumped. It's not that hard but I can't figure out why it's not working.

I need a macro which will check what the day of week is and ask me to confirm that I really want it to do its work before it does so. The pseudocode is:

get day of week
if day is Wednesday then
`set Proceed to true`
`ask user to confirm`
`if user responds yes then`
`> set Proceed to true`
`> set Proceed to false`
`end if`
end if
if Proceed is true then
`do the work`
end if

Here is my macro:
Do stuff.kmmacros (6.3 KB)

What I'm finding is that when I go Try it doesn't always carry out each step. And it never carries out the last one. If I make a change to the macro (e.g. changing "Wedn" to "Wedne") then it will bring out the confirm dialog, but on a subsequent Try it won't. And even if the final Growl tells me that Proceed is true, the Terminal is never launched.

What am I doing wrong? This should be simple! I've used If Conditions Met many times before. :confused:

Have you tried the Macro Debugger (KM Wiki)?

Your macro seems to work fine for me. I’m guessing the problem may be that when you click “Try” (assuming you mean the Try button at the bottom of the editor window) you expect it to try the entire macro. However, the Try button only tries the currently selected action, not the entire macro. I think this may explain why you’re experiencing what appears to be inconsistent behavior, since only trying individual actions in a condition-dependent macro like this will invariably skip some of the conditionals needed for the current action to work. If I’m correct, and you have been trying to test your macro only with the Try button in the editor, see if anything changes when you run the entire macro. If you still run into the same problems, I would then suggest taking @JMichaelTX’s advice and running the macro with the debugger.

1 Like

Oh, DUH! :blush: I didn’t know that, but it should have occurred to me as a possible reason for my symptoms. I figured that since each step has its own Try function, the Try button at the bottom would test the entire macro. So, is there a way of running a macro with the editor out? Or must I e.g. go to the KM status menu / click the palette button / press the key combo / etc?

Many thanks gglick

No problem! You’re not the only one who’s been confused by that Try button; I’ve made the same mistake myself. As for running the entire macro, it makes no difference if the editor is open or not; your macro will run as written even if you’re in the middle of editing it. That said, as far as I’m aware, there isn’t any special way of running a macro that’s currently being edited beyond invoking its current trigger, with the exception of the “Trigger Macro by Name” action (and similar workflows/extensions in Alfred and LaunchBar that let you trigger any macro by its name) that can let you run any active macro regardless of its assigned trigger.

Oh well, it was worth asking :slight_smile: Thanks again

1 Like

Thanks to our good friend @DanThomas, we have a great macro that will run whatever macro currently has focus in the KM Editor.
I have assigned CMD-F1 to this macro, so it is always easy to test.

###MACRO: Run Current Macro

1 Like

I happily stand corrected! Thanks for the tip; I can see this macro coming in very handy :smile:

Way cool! Thanks for mentioning it!