• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Tasker Variables global

cdikland

Newbie
Jan 14, 2013
21
1
Are variable defined by a task within one profile available to tasks within an other profile. In other words, are variable defined by tasks considered GLOBAL?? If so, then I dont understand why I cant get my If/endif block to work.
Here is what I got

Profile1 - Headphone plugged in run musicplayer, set var1=True, (Exit task) Headphone unplugged Go Home, set var1=False.

This works without fail however when I try to make use of var1 within an Exit Task of another profile such as

Profile 2 Exit task:
tsk1 -If var1=False
tsk2 do something
tsk3 endif


tsk 2 never executes even though I confirmed that var1 is set to False.

Any ideas??
 
Try changing your variable name from var1 to Var1 to change it from local to global variable.

Tasker for Android
Code:
Global vs Local Variables

All built-in variables are global, meaning they are visible anywhere in Tasker (e.g. %WIFI)
User variables which have one or more capital letters in their name are also global (e.g. %Car)

However, user variables which have all-lower-case names (e.g. %fruit) are local, meaning they are only visible in the task in which they are used (or the scene in which they are used, if the task was launched from by a scene event).

In general, it's best to use local variables wherever possible because:

you know they won't be interfered with by other tasks
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.
 
Upvote 0
Try changing your variable name from var1 to Var1 to change it from local to global variable.

Tasker for Android
Code:
Global vs Local Variables

All built-in variables are global, meaning they are visible anywhere in Tasker (e.g. %WIFI)
User variables which have one or more capital letters in their name are also global (e.g. %Car)

However, user variables which have all-lower-case names (e.g. %fruit) are local, meaning they are only visible in the task in which they are used (or the scene in which they are used, if the task was launched from by a scene event).

In general, it's best to use local variables wherever possible because:

you know they won't be interfered with by other tasks
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.

Thanks for the info. I'll keep that in mind for future reference, however...
In my original post/example I should have used what I actually had in Tasker which is:

1. if %powerAmpOn=False
2. Security Setting - Configuration Set Pin
3. endif

The above would not work however the following did

1. if %powerAmpOn ~ False
2. Security Setting - Configuration Set Pin


So... Did the last example work because I changed the = to ~ or because I removed the endif???
 
Upvote 0
According to the User Guide section on pattern matching
"Matches (~)
The right parameter is a pattern which the left parameter is matched against.
.
.
.
Equals (=)
As above, but the two parameters must be numerically equal."


If I interpret that correctly, you fixed it by replacing the operator used to compare numeric values (=) with the one that is to compare strings (~). Got bit by that myself the other day! :D

-IAmHe
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones