Problems with popup and variables

22 views
Skip to first unread message

Lars

unread,
Sep 17, 2022, 9:43:32 AMSep 17
to Tasker
Hi,
I tried using a popup for the first time today, and...it didn't work like I was hoping it would ;)

Anyway - long story short, I stopped trying to concatenate my string in the text field, and I even deleted the scene in case there was something wrong with it.

Now, this is what I'm doing in the problematic parts of the task:
1. variable add, name %numRun, Value 1 (it's being set earlier in the task)
2. JavaScriptlet, code var output = "Running entry - AGAIN ["  + numRun + "]"
3. Popup, title Running Text %output

What I'm getting is a box with "Running" as the header and "%output" as the text.

Anyone able to help me understand what I'm doing incorrectly here? I would've understood if the text part was blank (not set), but...I'm not really interested in seeing the name of the variable. I'm more interested in seeing how many times it was run.

I also tried displaying the variable in a notify action, but same output.

Brenden M

unread,
Sep 17, 2022, 1:55:14 PMSep 17
to Tasker
Just for trial sake, try "Output" or "OUTPUT" instead of "output" as these differences make the variables get used in "user/global/local" different ways. In essence, I think the step 3 might not get the lowercase "output" which is the way a "local"-only variable is written, and the way JavaScriptlet is working might not keep output retained AFTER step 2. Varying the capital letters (in your step 2 and 3 above, same case in each step) could make the Variable persist across actions through your task.

It's worth trying I think.

Brenden M

unread,
Sep 17, 2022, 1:57:36 PMSep 17
to Tasker
This is a source which might point the right direction:
https://groups.google.com/g/tasker/c/7GtY9fNKlxI

Lars

unread,
Sep 17, 2022, 2:34:15 PMSep 17
to Tasker
Thanks,
I tried "%OUTPUT", "%Output" and "OUTPUT" and they all just wrote it as plain text. The "%output" I had was picked from the list of variables presented when clicking the button over the text field...

Brenden M

unread,
Sep 17, 2022, 2:45:45 PMSep 17
to Tasker
The example I shared had a "Variable Set" but you just have Variable Add. Maybe you need to Set before you Add. The syntax is different in your case and the example I shared. Can you change your syntax and get the result you want? I am not familiar enough with Javascript to help troubleshooting that part. In particular, I think by Variable Set, the Javascriptlet might populate the var the right way. Perhaps, the syntax you're using is a bit like trying to put in apple in a basket, but without the basket, your apple is rolling away. Or the other way around. adding no apple and adding no apple again (or not being able to Add to "void"), all you have is the container %output.

Lars

unread,
Sep 17, 2022, 2:55:11 PMSep 17
to Tasker
That seems to be part of it :) I added a variable set for the %output, and now it shows the initial text (".") - but the javascriptlet doesn't seem to set it. As it's all lowercase it should be local, no? I don't want (or need) it to be globally available, and I want it destroyed when the task exits.

Brenden M

unread,
Sep 17, 2022, 4:28:18 PMSep 17
to Tasker
The error might be "local to the action step" and the Javascriptlet might not take Tasker local variables from prior actions while it might take %oneCapital for it to persist. For instance, %err in an action might only be relevant until another action had an %err and it might be tricky to keep things in order for multiple codebases, even if Tasker only actions could do what you're expecting/trying to make happen.

If the task will operate like this, and be able to use the variable, the last step of that task could be a Variable Clear %Output when it is no longer needed.

It might seem cleaner to just use local variables, but I do see potential issues arising crossing codebases like to "javascript". If you can get it to work without too much finicky workaround, Variable Clear of a project/user var might just be easy enough to do that it suits purposes.

Lars

unread,
Sep 18, 2022, 5:33:52 AMSep 18
to Tasker
Sorry for bothering you, but I tried changing this to a global variable. It doesn't seem like the javascriptlet does anything to the variable, though.

%output is now %Output. The javascriptlet is now -- global("Output") = "sometext" + numRun -- (I used "--" to denote the code as double quotes would just look strange with the other double quotes). This leaves %Output as the initialized value. I also tried adding "var" before the statement, but that just threw an error.

Lars

unread,
Sep 18, 2022, 5:45:05 AMSep 18
to Tasker
I've made a workaround that's "ok" (I would still like to know what's happening, though), where I do the concatenation directly in the alert() function.

Thanks :)

Reply all
Reply to author
Forward
0 new messages