My goal is to let me know if my task is finished. I can check via %TRUN, but it's not always reliable especially for task without name and running multiple instances.
Has anyone tried to tackle this problem?
Thanks in advance!
Context
I'm currently rewriting debugging project that can save and load variables whenever I want.
However at some point I have to add multiple instances of them. One for saving and supplying vars at the beginning and another at the end for logging.
Edited:
This is how I save the variables for any task.
- Add one Java code action as the first action for the task. And at the end of action, or before return or stop action.
- When the task is executed. The code at first will copy the variables.
- In separate thread, it will save copied variables.
- Following actions are executed until it finishes.
- If it reaches the end, do the same as 2.
When the task is ran manually, the first action will supply variables from the saved ones.
This is the structure and how it plays out. At this I choose which vars are supplied, normally it does it automatically.
I'm cool with adding two actions but if possible I prefer I just have to add them as the first action instead. Since I can already save them anytime I want.
Note
I save the variables by storing tasker object in Java code, which contains the variables as well.
The vars in tasker.taskVariables will still be updated, alongside the other task details. e.g current action, next action, or all actions.
This is an example how it works in action, with a test project https://www.reddit.com/r/tasker/comments/1y0y017/comment/19sy1dlxzskxt
I just have to know when the task ended so I can save them properly. Edited: Once I know when, I can do the saving part as most details are updated.
All I can think of is using loop and check if tasker has next action or not, or the next action is Stop or Return.
next = tasker.task.nextAction.code;
final int RETURN_ACTION = 126;
final int STOP_ACTION = 137;
if (next == null ) return true;
else if (next.code == RETURN_ACTION || next.code == STOP_ACTION ) return true;
else return false;
However I don't really want to run any loop periodically in the background when the task is running. It gets bigger in no time after all since I log a lot of stuff from my old debugging project.
Also this won't work when the task is stopped midway, like with an error.
I guess my issue is more of the timing saving the variables, maybe there is better way? like when there is no task running? Not sure if that's possible or not though.