One Perform Task Thread To Rule Them All

27 views
Skip to first unread message

Christopher Scott

unread,
Dec 2, 2016, 5:30:42 PM12/2/16
to Tasker
I'm having a hard time with the Perform Task action, and, apparently, so is a significant number of the Tasker user community. So, let's see if we can sort this out once and all.

First, please excuse me if I write something that has been written before.

Second, I'm going to make this post very general so people can more easily apply the answers to their specific 'Perform Task' circumstances.

In this example, I want to pass two variables to a child task, have those variables divided (÷) in the child task, and have the result passed back as a variable to the parent task, and then take action on the variable received.

In the parent task, the set of actions should flow like this:

BEGIN

-> Set Vatiable %dividend to 20
-> Set Variable %divisor to 5
-> Perform Task 'Divide Integers'. (This is the child task.) The following should be passed to / received from the child task.

• %dividend as %par1
• %divisor as %par2
• %quotient as return value

The child task's priority is set to 'priority+1'.

After the child task completes, the parent tasks continues.

-> The variable %quotient is stored in %result (Really, this action is performed in the call to Divide Integers.)
-> If %result is even
• Flash :)
-> Else If
• Flash :(

STOP

So here are some basic questions:

1. When %dividend and %divisor are passed to the child task Divide Integer, does the Action Perform Task expext they will be entered into the parameters fields as 'dividend' and 'divisor' (without the % symbol in front of the variables' names) or are they entered as %dividend and %divisor?

2. When the child task receives the two variables passed to it, how are these referenced in the Child Task? As %par1 and %par2? As %dividend and %divisor?

3. When the child task (Divide Integer) returns a variable, is that variable named as the local variable %quotient or as quotient (without the % symbol) when it is received?

4. When the Parent Task receives the return value from the child task, does the receiving variable have to be named the same as the variable passed from the child task? (In this example, the parent task would have to store the received value in a variable named %quotient.) Alternatively, can the value of %quotient be stored in a new local variable named whatever is self documenting (for example, %result)?

5. When calling a child task, if the priority of the child task is assigned as 'priority+1', the child task will always complete before the parent task moves to its next action, right?

I know these are basic questions, but there seems to be a lot of confussion out there about the action Perform Task.

I know all the questions above can be solved using global variables (for example, %Quotient instead or %quotient), but this inelegant solution creates all sorts of variables most tasks have no use for. Tasker users are admonished to avoid this practive in a couple different locations in the documentation.

When answering, please just refer to the question number above.

Pent, if you take a look at this, would you mind testing the action to make sure it works? It seems the Perform Task might be buggy.

Best,
Christopher

Rich D

unread,
Dec 2, 2016, 6:32:24 PM12/2/16
to Tasker Google Groups Post




> In the parent task, the set of actions should flow like this:
>
> BEGIN
>
>   -> Set Vatiable %dividend to 20
>   -> Set Variable %divisor to 5
>   -> Perform Task 'Divide Integers'. (This is the child task.) The following should be passed to / received from the child task.
>
>      • %dividend as %par1
>      • %divisor as %par2
>      • %quotient as return value
>
> The child task's priority is set to 'priority+1'.
>
> After the child task completes, the parent tasks continues.
>
>   -> The variable %quotient is stored in %result (Really, this action is performed in the call to Divide Integers.)
>   -> If %result is even
>         • Flash :)
>   -> Else If
>         • Flash :(
>
> STOP
>
> So here are some basic questions:
>
> 1. When %dividend and %divisor are passed to the child task Divide Integer, does the Action Perform Task expext they will be entered into the parameters fields as 'dividend' and 'divisor' (without the % symbol in front of the variables' names) or are they entered as %dividend and %divisor?

The % is required for any variable in Tasker actions. The exceptions will only be for the code actions such as javascript .

>
> 2. When the child task receives the two variables passed to it, how are these referenced in the Child Task? As %par1 and %par2? As %dividend and %divisor?

%par1 and %par2

>
> 3. When the child task (Divide Integer) returns a variable, is that variable named as the local variable %quotient or as quotient (without the % symbol) when it is received?
>

See answer for #1

> 4. When the Parent Task receives the return value from the child task, does the receiving variable have to be named the same as the variable passed from the child task? (In this example, the parent task would have to store the received value in a variable named %quotient.) Alternatively, can the value of %quotient be stored in a new local variable named whatever is self documenting (for example, %result)?

Yes. Put %result in the 'Return value variable'  option in the preform task action.

>
> 5. When calling a child task, if the priority of the child task is assigned as 'priority+1', the child task will always complete before the parent task moves to its next action, right?

Correct.

> I know all the questions above can be solved using global variables (for example, %Quotient instead or %quotient), but this inelegant solution creates all sorts of variables most tasks have no use for. Tasker users are admonished to avoid this practive in a couple different locations in the documentation.

Global variables are not necessary.

> Pent, if you take a look at this, would you mind testing the action to make sure it works? It seems the Perform Task might be buggy.

If you find a bug then report it here, along with the exported task descriptions.  

The preform task action has no known bugs at this point in time. It is a very common action and used by many. So if there were bugs they would most likely have been reported.

Christopher Scott

unread,
Dec 2, 2016, 7:44:28 PM12/2/16
to Tasker
Thanks, Rich. Im sure this will help more than me!

Rich D

unread,
Dec 2, 2016, 7:51:17 PM12/2/16
to Tasker Google Groups Post


Forgot to include this...




To post your profile or task here...  Long press on the profile or task name / ( 3 dot menu with 4.0+ ) export / export "DESCRIPTION" to clipboard (not XML)

Any linked tasks will be exported with the profile they are linked to..

To be able to export, The beginner mode needs to be off and the profile needs to be named by you (Not the Tasker listed name.  Tasker will list your profile with the context name if you have not given it one).


Reply all
Reply to author
Forward
0 new messages