Create a variable whose value is the name of the current task.

Please provide a way to get the name of the currently running task (and only that task). 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).

5 replies

I just came across this the other day where I really needed the name of the Task available as a variable inside the Task itself.

Since we've already got: %err, %errmsg, %priority, %qtime, and %caller - it makes perfect sense to have a local of something like %taskname.

The only issue being if the name chosen is already in use by people in their existing Tasks all over the place.

Then I saw Rich D's idea here and think that is the PERFECT WAY to do this. Just add it to "Test Tasker" as "Name of this Task" :) 

For me, it would make sense to have a %task variable in a similar way as the %caller1 and %caller2 variables. The only difference is that it would only contain the task name.

I don't know about `%LASTTASK` but the name of the current task isn't limited to testing/debugging only.

I also like the idea of %LASTTASK. This would be handy if a rogue Task were causing an unexpected issue.  These variable could be used to troubleshoot or have other uses. 

I would think the best place for this would be in the 'Test Tasker' action. 

This is most definitely the best solution for this. Adding a new local variable name (to the existing %qtime, %caller, etc) runs into the problem of people all over the place who happen to be using the newly chosen variable for something in their existing Tasks already.

To make it into a manual action, with an output variable needing to be chosen by the user - solves that problem completely. Great idea!!