Best way to create a reusable "Assert"?

I wish there was an Action called "Assert", where I could specify a condition (usually involving a variable) and if the condition is false, I would do a Notification with some text I specify, and "Cancel this Macro".

I can, of course, do something like this:

But being the anal person I am, I would also want to rename the "If" action and collapse it like this:

This naturally got me to thinking that, if no "Assert" action is forthcoming from Peter (and I wouldn't expect it to be high on his list), there's got to be some way to automate creating this code. I just can't quite come to grips with how to accomplish it.

I could do some really kludgy combination of Prompt, Paste from Named Clipboard, tab keys, inserting text, right-clicking on a found image to rename the "IF", and clicking a found image to collapse the result.

Could be done, of course. In fact, in lieu of any other ideas, I'll probably do just that. But I was hoping there was a way that didn't "smell" as much.

Any ideas?

PS: "Asserts" are awesome, and help debug complex code, especially when you have macros calling each other. Each sub-macro makes some assumptions, and Asserts double-check the assumptions so if you change something somewhere and it breaks something down the line, you know why.

1 Like

Thanks to @ccstone's other post on Attributions, I have my solution:

I was wondering if I could do an Import Action, but couldn't see a way to do it. Now I know how.

So all I have to do is manipulate the Action(s) XML, and import it like this. Awesome.

Assuming this works, expect to see it in the Macros section. All 2 of you who will use it. :stuck_out_tongue:

Hey Dan,

It should be quite simple to write a plugin to do exactly that.

-Chris

Thanks. I’ve basically got it working, but I’m still have a few things to perfect. Just grunt work left now, Thanks!