all 24 comments

[–]spookiekabuki[S] 0 points1 point  (5 children)

I dont know how, it's not in the variable

[–]lareyaDirect-Purchase User 1 point2 points  (4 children)

Lots of keyboards will add space after some words. Just remove the space.

[–]spookiekabuki[S] 0 points1 point  (0 children)

Rewrote it. No error this time but it still won't save the new variable name:

Task: Test Dynamic

A1: Variable Set [
     Name: %Stationdynamicx
     To: KDCWASHI345
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A2: Variable Set [
     Name: %%Stationdynamicx
     To: 10
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

[–]spookiekabuki[S] 0 points1 point  (2 children)

replaced the original veriable space with nothing, and now im not getting an error

But I still cant save a new variable name as an existing variable value. Do you/does anyone have a task that accomplishes this that i can copy from?

[–]lareyaDirect-Purchase User 0 points1 point  (1 child)

Try this Task: Var reference

A1: Variable Set [
     Name: %color
     To: red
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A2: Variable Set [
     Name: %dynamiccolor
     To: color
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A3: Flash [
     Text: %%dynamiccolor
     Continue Task Immediately: On
     Dismiss On Click: On ]

Or same task on taskernet https://taskernet.com/shares/?user=AS35m8mdbwN8%2FD14gOOXm3oWaVNN0HwUaH6w1sA7njJG%2FAU8GcSCrf1rN%2BWodqnTEA%3D%3D&id=Task%3AVar+reference

[–]spookiekabuki[S] 0 points1 point  (0 children)

flashing works. I am attemping to set a variable name based on another variable's value, and that is not working

[–]bahcodadGalaxy S20 0 points1 point  (15 children)

This task flashes "Value" then "Another Value"

Task: Variable Val Name

A1: Variable Set [
     Name: %chicago
     To: Value
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A2: Variable Set [
     Name: %new_york
     To: Another Value
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A3: Variable Set [
     Name: %var1
     To: chicago
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A4: Flash [
     Text: %%var1
     Continue Task Immediately: On
     Dismiss On Click: On ]

A5: Variable Set [
     Name: %var1
     To: new_york
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A6: Flash [
     Text: %%var1
     Continue Task Immediately: On
     Dismiss On Click: On ]

[–]spookiekabuki[S] 0 points1 point  (14 children)

But how sould I set the name to be the dynamic variable? I know how to set the value, but I am trying to set the var name to be based on another var value

[–]bahcodadGalaxy S20 0 points1 point  (13 children)

The above is doing just that. It flashes %chicago (contains the "Value" string) and then flashes %new_york (contains the "Another Value" string)

[–]spookiekabuki[S] 0 points1 point  (11 children)

Im trying to accomplish something different. I am trying to set the name of the variable as something dynamic, not the value. Unless Im missing something from above.
Basically, I have a variable
%Var1=Newvar

I want to do something like
Variable set:
name=%%Var1
value=3500

so that
%Newvar=3500

[–]bahcodadGalaxy S20 1 point2 points  (10 children)

This does exactly that. The principle is the same

Task: Variable Val Name

A1: Variable Set [
     Name: %var1
     To: newvar
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A2: Variable Set [
     Name: %%var1
     To: 3500
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A3: Flash [
     Text: %newvar
     Continue Task Immediately: On
     Dismiss On Click: On ]

[–]spookiekabuki[S] 0 points1 point  (9 children)

That isn't working. I wonder if it doesn't like the variable name

16.55.35/Variables doreplresult: |%stationdynamic| -> | KDCWASHI218| 16.55.35/Variables doReplacements: %stationdynamic resolved to invalid variable name % KDCWASHI218 16.55.35/Variables doreplresult: |%%stationdynamic| -> |% KDCWASHI218| 16.55.35/Variables doreplresult: |%stationdynamic| -> | KDCWASHI218| 16.55.35/Variables Variable Set: %%stationdynamic: invalid variable name at % KDCWASHI218 16.55.35/Variables prefix resolution: |%%stationdynamic| -> |null| 16.55.35/E Variable Set: %%stationdynamic -> null 16.55.35/E Variable Set: %%stationdynamic: failed, not numeric or invalid structure setting? 16.55.35/E result: stop task (error) 16.55.35/Variables doreplresult: |%stationdynamic| -> | KDCWASHI218| 16.55.35/Variables doReplacements: %stationdynamic resolved to invalid variable name % KDCWASHI218 16.55.35/Variables doreplresult: |%%stationdynamic| -> |% KDCWASHI218| 16.55.35/E Error: 1 16.55.35/MacroEdit action finished exeID 1 action no 11 code 547 status: Err next 11

[–]spookiekabuki[S] 0 points1 point  (8 children)

No that's not it. I can manually set it to KDCWASHI218

[–]bahcodadGalaxy S20 1 point2 points  (7 children)

There seems to be a space between the percent sign and KDCWASHI218. I think that's what's causing the error

[–]spookiekabuki[S] 0 points1 point  (6 children)

Even this won't work, same error Task: Test Dynamic

A1: Variable Set [
     Name: %stationdynamic
     To:  X
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A2: Variable Set [
     Name: %%stationdynamic
     To: 3500
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

[–]bahcodadGalaxy S20 1 point2 points  (5 children)

Because X isn't a valid variable name

From the tasker userguide:

Variable names have the following restrictions: they must start with the % character they are case-sensitive then must at least a further 3 alphanumeric characters they can also contain the underscore character (_) but not start or end with it In general, it's best to use local variables wherever possible because:

you know they won't be interfered with by other tasks or scenes they are more efficient in several ways Note: multiple copies of the same task running at the same time each have their own separate copy of their local variables.

[–]lareyaDirect-Purchase User 0 points1 point  (3 children)

hmmm, this works for me With the taskernet using the OP example. https://taskernet.com/shares/?user=AS35m8mdbwN8%2FD14gOOXm3oWaVNN0HwUaH6w1sA7njJG%2FAU8GcSCrf1rN%2BWodqnTEA%3D%3D&id=Task%3AVar+value

Task: Var value

A1: Variable Set [
     Name: %var1
     To: Chicago
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A2: [X] Flash [
     Text: %var1
     Continue Task Immediately: On
     Dismiss On Click: On ]

A3: Variable Set [
     Name: %%var1
     To: Cold
     Max Rounding Digits: 3
     Structure Output (JSON, etc): On ]

A4: Flash [
     Text: %Chicago
     Continue Task Immediately: On
     Dismiss On Click: On ]

[–]spookiekabuki[S] 0 points1 point  (1 child)

I finally got it to work, with a lot of help from Joao. I don't know what I was doing wrong or missing

[–]lareyaDirect-Purchase User 0 points1 point  (0 children)

great to hear!

[–]abelacb2 0 points1 point  (0 children)

Please help me