1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Tasker Variables global


Last Updated:

  1. cdikland

    cdikland Member This Topic's Starter

    Joined:
    Jan 14, 2013
    Messages:
    21
    Likes Received:
    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??
     

    Advertisement
  2. electricpete

    electricpete Well-Known Member

    Joined:
    Jan 7, 2012
    Messages:
    2,049
    Likes Received:
    1,004
    Try changing your variable name from var1 to Var1 to change it from local to global variable.

    Tasker for Android
    Code (Text):
    1. Global vs Local Variables
    2.  
    3. All built-in variables are global, meaning they are visible anywhere in Tasker (e.g. %WIFI)
    4. User variables which have one or more capital letters in their name are also global (e.g. %Car)
    5.  
    6. 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).
    7.  
    8. In general, it's best to use local variables wherever possible because:
    9.  
    10. you know they won't be interfered with by other tasks
    11. they are more efficient in several ways
    12. Note: multiple copies of the same task running at the same time each have their own separate copy of their local variables.
     
  3. cdikland

    cdikland Member This Topic's Starter

    Joined:
    Jan 14, 2013
    Messages:
    21
    Likes Received:
    1
    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???
     
  4. IAmHe

    IAmHe Member

    Joined:
    Oct 2, 2010
    Messages:
    9
    Likes Received:
    1
    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
     

Share This Page

Loading...