Variable for Current Task Name?

950 views
Skip to first unread message

Darth Bob

unread,
Nov 9, 2011, 11:29:48 AM11/9/11
to Tasker
Is there a variable where the name of the current task being executed
is stored? Or some other way to determine it other than hardcoding it
into the task itself?

Thanks.

BossMan

unread,
Nov 9, 2011, 11:34:07 AM11/9/11
to tas...@googlegroups.com

Darth Bob

unread,
Nov 9, 2011, 1:18:51 PM11/9/11
to Tasker
Thanks for the input. I had found that one, but that's not quite what
I'm looking for.

What I want to do is find the name of the task that is CALLING the
current step, indpendent of whether there are other tasks running at
the same time or not, so that I can save that to a variable and then
call that task from another task, depending on the results of that
task.

Thanks.

Pent

unread,
Nov 9, 2011, 1:54:16 PM11/9/11
to Tasker
> What I want to do is find the name of the task that is CALLING the
> current step,

'Step' ? You mean calling the current task ? Put the name in a
parameter.

Pent

Darth Bob

unread,
Nov 9, 2011, 3:05:39 PM11/9/11
to Tasker
That's what I currently do - I hardcode the name of the task into the
task. I was hoping that there was an easy way to capture the name of
the task and put it into a variable, so that if I ever decide to
change the name of the task, I don't have to go in to change the
hardcoding. Constructive laziness, don't'cha know. :-)

Peter Bongé

unread,
Mar 10, 2012, 7:30:09 AM3/10/12
to tas...@googlegroups.com
I was searching for the same thing.
I have several tasks where I set the task name to a variable and then use the "Flash" action to show the task name.
If I want to rename the tasks I have to rename 3 things for every task and that is not really nice. A variable with the current task name would really be helpful!

Noel Yap

unread,
Jun 17, 2018, 2:11:17 AM6/17/18
to Tasker
This can be done by Splitting %TRUN then accessing %TRUN(2).

Noel

Noel Yap

unread,
Jun 19, 2018, 9:37:45 AM6/19/18
to Tasker
It looks like this works only if one main task is running which, unfortunately, defeats the purpose.

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

nanobrain

unread,
Jun 19, 2018, 9:57:22 AM6/19/18
to Tasker
This thread is ancient, there has been for a while:

  • Task Caller
    %caller
    A variable array tracing the origin of the current running task. %caller1 gives the origin of the current task, %caller2 the origin of %caller1 etc.

    Example: if task A uses action Perform Task to start task B, then when task A is run by pressing the Play button in the task edit screen, %caller1 in task B will show task=A, %caller2 will show ui.

    The format of each entry in the array is callertype(=callername(:subcallername))

    Caller types ares detailed below:

    • profile
      a profile (when it's state changes). callername is either enter or exit depending on whether the profile activated or deactivated. subcallername is the name of the profile, if it has one, otherwise anon
    • scene
      a scene event, with callername being the scene name. For element events, subcallername is the element name. For action bar button presses, subcallername is the label if one was given. For scene-global events (e.g. Key), subcallername is event type
    • ui
      the Play button in the task edit screen in the Tasker UI
    • launch
      clicking a child application icon in the launcher
    • nbutton
      a notification action button, either from Tasker's permanent notification or one created with one of the Notify actions. callername specifies the label of the button if present.
    • external
      an external application
    • qstile
      a Quick Settings tile. callername specifies the label of the tile.
    • appshort
      an app shortcut (accessed via long-click on the Tasker icon). callername specifies the label of the tile.
    • task
      another task, from a Perform Task action. subcallername is the task name, if it has one, otherwise anon

Robert Ryan

unread,
Jun 19, 2018, 10:37:06 AM6/19/18
to tas...@googlegroups.com

Unfortunately, none of those variables contain  the current task's name.

Noel Yap

unread,
Jun 19, 2018, 1:16:37 PM6/19/18
to tas...@googlegroups.com

On Tue, Jun 19, 2018 at 7:36 AM Robert Ryan <rbr...@gmail.com> wrote:

Unfortunately, none of those variables contain  the current task's name.

--

Rich D

unread,
Jun 19, 2018, 3:25:29 PM6/19/18
to Tasker Google Groups Post
You could have  have an additional task that you do a preform task action to and get the returned task name of the calling task.  It would involve two actions and one additional tasks. 

Lewis Peano

unread,
Jun 19, 2018, 3:51:39 PM6/19/18
to tas...@googlegroups.com
Thanks. Do you have a way of doing this in laymans terms? Sorry I'm not very experienced 

Thanks

On Tue, 19 Jun 2018, 20:25 Rich D, <ricp...@gmail.com> wrote:
You could have  have an additional task that you do a preform task action to and get the returned task name of the calling task.  It would involve two actions and one additional tasks. 

--

Noel Yap

unread,
Jun 19, 2018, 5:36:53 PM6/19/18
to tas...@googlegroups.com
Is there a way to return values from tasks without setting another variable? If not, care must be taken against race conditions.

On Tue, Jun 19, 2018 at 12:25 PM Rich D <ricp...@gmail.com> wrote:
You could have  have an additional task that you do a preform task action to and get the returned task name of the calling task.  It would involve two actions and one additional tasks. 

--

Rich D

unread,
Jun 19, 2018, 8:36:32 PM6/19/18
to Tasker Google Groups Post
parent task (626)
A1: Perform Task [ Name:return task name Priority:%priority+1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable:%this_task_name Stop:Off ] 
A2: Flash [ Text:%this_task_name Long:On ] 

return task name (627)
A1: Variable Set [ Name:%temp To:%caller(>) Recurse Variables:Off Do Maths:Off Append:Off ] 
A2: Variable Split [ Name:%temp Splitter:= Delete Base:Off ] 
A3: Return [ Value:%temp2 Stop:On ] 

Noel Yap

unread,
Jun 20, 2018, 12:09:48 PM6/20/18
to Tasker
Correction, this should be `%TRUN(<)`.

On Sat, Jun 16, 2018, 23:11 Noel Yap <noel...@gmail.com> wrote:
--

Noel Yap

unread,
Jun 20, 2018, 12:10:37 PM6/20/18
to tas...@googlegroups.com
I just learned that Tasker has local be l variables so the race condition issue can be avoided.

Rich D

unread,
Jun 20, 2018, 12:45:45 PM6/20/18
to Tasker Google Groups Post
Correction, this should be `%TRUN(<)`.

I do not believe the last (or first) name in %TRUN is guaranteed to be the current task.  But there is a guaranteed order in %caller

Noel Yap

unread,
Jun 20, 2018, 2:59:19 PM6/20/18
to tas...@googlegroups.com
I'm trying to log the value of `%caller`. How do I go about doing that? I'm not seeing a way to join the array and log the value of that.

Thanks,
Noel

On Wed, Jun 20, 2018, 09:45 Rich D <ricp...@gmail.com> wrote:
Correction, this should be `%TRUN(<)`.

I do not believe the last (or first) name in %TRUN is guaranteed to be the current task.  But there is a guaranteed order in %caller

--

Rich D

unread,
Jun 20, 2018, 6:23:34 PM6/20/18
to Tasker Google Groups Post

I'm trying to log the value of `%caller`.

what do you mean by log ?

variable set %my_var TO: %caller()  will set %my_var to a comma seperated  list of all the array elements of %caller. 


How do I go about doing that? I'm not seeing a way to join the array and log the value of that.

The task descriptions I provided should work for what you want.

Noel Yap

unread,
Jun 21, 2018, 10:00:00 AM6/21/18
to tas...@googlegroups.com
I'm "logging" by pushing onto an array.

When I try what you're suggesting, I get an error saying the task that's returning the name doesn't exist. Any idea what might be going wrong?

On Wed, Jun 20, 2018, 09:45 Rich D <ricp...@gmail.com> wrote:
Correction, this should be `%TRUN(<)`.

I do not believe the last (or first) name in %TRUN is guaranteed to be the current task.  But there is a guaranteed order in %caller

--

Noel Yap

unread,
Jun 21, 2018, 10:10:15 AM6/21/18
to tas...@googlegroups.com
Ah, there was some caching going on. I just had to hit the check mark at the top to clear it.

Noel Yap

unread,
Jun 22, 2018, 12:13:51 AM6/22/18
to tas...@googlegroups.com
I was able to replace the first two steps with a search and replace:
Variable: %caller(>)
Search: (?<=task=).*
Store Matches In: %result

Rich D

unread,
Jun 22, 2018, 4:57:01 AM6/22/18
to Tasker Google Groups Post

I was able to replace the first two steps with a search and replace:
Variable: %caller(>)
Search: (?<=task=).*
Store Matches In: %result


Does this work around seem to work for your needs?

Could you explain a bit more of what you are trying to do here.

This would allow tasks to push themselves on to a stack and have other tasks pop off the stack and execute those tasks (eg to set and reset volume profiles).

There could be a alternative approach. 

Noel Yap

unread,
Jun 22, 2018, 9:33:47 AM6/22/18
to tas...@googlegroups.com
Yes, I'm trying to push and pop task names onto a stack.

The solution you had provided with "return task name" works fine. I just found a way to do it in two steps rather than three and wanted to share for the benefit of those interested.

--
Reply all
Reply to author
Forward
0 new messages