Go Back   Android Forums > Android Discussion > Android Applications > Tasker

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old January 14th, 2013, 03:28 PM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Jan 2013
Posts: 21
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 1 Time in 1 Post
Default Tasker Variables global

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??

cdikland is offline  
Reply With Quote
sponsored links
Old January 14th, 2013, 09:49 PM   #2 (permalink)
Senior Member
 
Join Date: Jan 2012
Posts: 682
 
Device(s):
Carrier: Not Provided

Thanks: 164
Thanked 139 Times in 109 Posts
Default

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.
electricpete is offline  
Reply With Quote
Old January 15th, 2013, 02:34 AM   #3 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Jan 2013
Posts: 21
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by electricpete View Post
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???
cdikland is offline  
Last edited by cdikland; January 15th, 2013 at 02:37 AM.
Reply With Quote
Old January 15th, 2013, 04:44 PM   #4 (permalink)
New Member
 
Join Date: Oct 2010
Posts: 9
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 1 Time in 1 Post
Default

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!

-IAmHe
IAmHe is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Discussion > Android Applications > Tasker
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:17 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.