Perform Task action. To use it as a subroutine, you just need to ensure that the priority of the calling task is less than the priority of the called task (more info: scheduling).The parent can optionally pass values to the child and receive a result back:
Parent Task
| 1. | Perform Task Child, Priority, 10 %par1, 5, Result Value Variable, %result | pass 5 to the child, expect a result in %result |
| 2. | Variable Flash Result: %result | what did we get back ? |
Child Task
| 1. | Variable Set %newval, %par1 + 1, Do Maths | add one to the value that was passed |
| 1. | Return %newval | set %result in the parent to the value of %newval in the child |
Result: the parent flashes 6
Notes:
Return statements in most computer languages, Tasker's does not necessarily stop the child task, so if the child and parent have the same priority they can both run together and the child return several results over time.
My project has a MAIN task, which calls a series of sub-tasks.
The documentation says: "To call another task, use thePerform Taskaction. To use it as a subroutine, you just need to ensure that the priority of the calling task is less than the priority of the called task"
However, I can't see where to set the priority of each task?
> Not sure why the same task runs successfully once and then doesn't take a photo the next three times. Hmmm...
To check the flow you can turn on the run log and check it -- menu / more / run log
You might just need a wait in-between the perform tasks.
Rich...
> Now I'll either (a) reduce the wait duration to limit the delay OR preferably, (b) try to make it wait until the sub-task isn't running. There's a command for listing the active tasks, I believe.
>
The problem is the sub tasks are going to fast for the camera app, so
I think it will have to be 'a'. Or perhaps some test to see when a new file has been added to your DCIM/CAMERA file...
Rich.....
So something like this:
set add var %taken plus 1
set var %local to %FOTO
take photo
stop if %taken > 3
while %local doesn't equal %FOTO, wait 1 second
goto action 1
while %local = %FOTO, wait 1 sec
Tom