Struggling with conditionals every time

I always have a hard time with IF THEN ELSE conditionals in KM.

I created a "Prompt for user input" and modified the buttons to be YES and NO (neither will cancel the macro)

Can someone please explain to me how to execute an action if the YES button was pressed and a different action if the NO button was pressed?

I always struggle with this concept in KM. And I know this has been said many many times but Quickeys makes this easy.

Thanks, Xavier

Hi Xavier,

After putting together this macro, I reread your post and saw that you are talking about the buttons. So this macro approaches it a different way. With KM there are usually multiple ways to approach things, and this is probably not the best way - but it serves the purpose, but it doesn't make use of the buttons how you wanted it. Someone else can certainly help, but I hope this is a start.

I made two separate If Then actions to account for someone entering a non Yes/No answer and it just displaying the 'otherwise' action. The buttons in my example serve more as 'submit' or 'cancel' buttons. In fact, I would change the button labels to reflect that in retrospect!

2 Likes

Have you read the If Then Else action in the KM Wiki?

The KM If/Then Action works pretty much like If/Then statements in most languages.

  • IF (some criteria is TRUE) THEN do this stuff
    • ELSE do this other stuff

Does that make sense to you?

Or, perhaps the confusing part is:

  • What criteria (what KM call "Conditions") to use?
    OR
  • What Actions to put in the THEN block and ELSE block?

If/Then statements are one of the most basic flow control statements (Actions). To get the most out of KM, you need to master the use of it. Perhaps you can create a test Macro, and play with different Conditions and Actions.

Questions?

1 Like