1. Are you ready for the Galaxy S20? Here is everything we know so far!

Tasker Variables global

Discussion in 'Android Apps & Games' started by cdikland, Jan 14, 2013.

  1. cdikland

    cdikland Newbie
    Thread Starter

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

    1. Download the Forums for Android™ app!


  2. electricpete

    electricpete Android Expert

    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
    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)
    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).
    8. In general, it's best to use local variables wherever possible because:
    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 Newbie
    Thread Starter

    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 Lurker

    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



Tasker Forum


⚙No repetitive tasks for you, let your Android device handle it!⚙
Total Automation, From Settings to SMS. Here are only some
of the things you could do with Tasker. Its real power is the flexibility to combine contexts and tasks however you wish: https://tasker.joaoapps.com/exampleuses.htmlAutomations
Make your phone a true smart
phone! Why remember to change the volume every day when you leave home when your phone can do it for you? Automate stuff based on the app you're in
, the time of day
, your location
, your Wi-Fi network
, Received SMS or Calls
, the currently playing song
and many other (130+) states and events! Check out how easy it is to create an automation: https://www.youtube.com/watch?v=s6EAbLW5WSkActions
350+ actions allow you to truly customize your phone like never before! Send SMS, create notifications, change almost any system setting like Wifi Tether, Dark Mode, Always On Display, change any volume, control Do Not Disturb, open apps, file manipulation, control music playback, get your location... you get the idea. If you can think of it, Tasker can probably do it for you! Note: root is NOT (I repeat NOT) required for majority of the functions.
However, a few of the actions (like the Airplane Mode action and the Mobile Data action on some devices) require root. Regarding those few actions that do require root, this is because of Android security policies that developers cannot work around. ☑ Other Triggers
Manually trigger your actions via launcher shortcuts, quick setting tiles, widgets, long-pressing volume buttons, media buttons (like the ones on your BT headsets or headphones), Bixby button, Navigation Bar, Notificaitons and more! ☑ Join - Remote Tasker
Adding Join (https://play.google.com/store/apps/details?id=com.joaomgcd.join) to the mix will even allow you to trigger tasks from another Android device or PC! ☑ Scenes
Design your own UI and use it to display any info you want or trigger any task! ☑ App Creation
Create your own standalone apps to share or sell with the Tasker App Factory (https://play.google.com/store/apps/details?id=net.dinglisch.android.appfactory)! ☑ Developer Friendly
A lot of 3rd party developers already allow you to perform actions in their apps and listen to their events/states through Tasker! Check out a list of plugins https://tasker.joaoapps.com/pluginlist.html. You can also call most of the Web APIs from Tasker with the powerful HTTP Auth and HTTP Request actions! Check out an example https://youtu.be/yAt2D1XmgUI. ☑ 7 day trial - one time payment to unlock
Get it here: https://tasker.joaoapps.com/download.htmlUseful Links
Starter Guides: https://tasker.joaoapps.com/guides.html Pre-made projects: https://forum.joaoapps.com/index.php?resources/ Official Support Forumhttps://groups.google.com/forum/#!forum/tasker Community full of people willing to help: https://www.reddit.com/r/tasker/ It's not possible to fix problems reported via Play Store Comments so please use the "Report Issue To Developer" option in the app > Menu to do so. Note
: Tasker uses the BIND_DEVICE_ADMIN permission in order to provide the System Lock functionality

February 15, 2020
Last Updated

Share This Page