Tasker Tip Tuesdays

Tasker Tip Tuesdays: How to Use Multiple Action If Conditions

Multiple Action If Conditions

Welcome to Tasker Tip Tuesdays​, quick tips to help grow your Tasker knowledge.  This week I discuss how to use multiple Action If conditions.  If you need an Action to execute only when multiple parameters are met, this tip is for you.

 

Multiple Action If Conditions




While this is not a new feature, if conditions have been around for awhile.  However upon release of V4.3 on 06/04/2014 Pent gave us the opportunity to use more than one if condition.  Using If conditions requires a condition operator.  Those operators are “And”, “Or”, and “Xor”.  Defined below or see the user guide:

  • “And”: both conditions shall be to true
  • “Or”: at least one of the conditions shall be to true
  • “Xor”: only one of the conditions shall be to true

It is very straight-forward to understand when only using one of the above conditions.  However, the confusion occurs in situations with multiple conditions. Tasker prioritizes the 3 operators from highest to lowest, shifting them to the right relative to the lower priority ones: And, Or, and Xor.  But what if you have a situation where an “Or” needs to be evaluated at a higher priority than an “And”?  Tasker also handles those situations by adding a “+” symbol.  It also further shifts the operator to the right.  Tasker maintains the priority as such (these retain a higher priority than the none “+” mentioned above): And+, Or+, and Xor+.

Now that we have our priorities straight, (see what I did there?) it is important to understand how they work together when using combinations of all the above (6 total).  The best way, I have found, to understand this concept is to think of each operator surrounded by parentheses.  When thinking parentheses, think (PEMDAS).  Simply add a set of parentheses around the highest priority operator and evaluate the expression accordingly.  From here on, rinse and repeat until finished.

Examples

Here are some examples with and without parentheses to visualize the above:

  • First, try one operator
    • True & True evaluates to True
    • True | False evaluates to True
    • False X| False evaluates to False
  • Next, add a second operator (parentheses examples)
    • True & True |+ False  evaluates to True
    • True & ( True |+ False ) evaluates to True
    • True X| True X|+ False  evaluates to False
    • True X| ( True X|+ False ) evaluates to False
  • Finally, try three operator (parentheses examples)
    • True & False | True |+ False evaluates to True
    • ( ( True & False ) | ( True |+ False ) ) evaluates to True
    • True X|+ False & True |+ False evaluates to True
    • ( ( True X|+ False ) & ( True |+ False ) ) evaluates to True

Furthermore, see my video example of the above along with more samples.

Conclusion




So next time you have a complicated combination of multiple Action If conditions you only have to remember one thing.  Parentheses are your friends!  In fact, I usually take a piece of paper to write out my full equation before using them.  Because of that, I understand the logic and my Tasks work every time!

Further Reading

To catch up on previous posts in this series, visit the Tasker Tip Tuesdays page.  As always, enjoy and keep learning!  Until the next Tasker Tip Tuesday…

What did you think???