Real-time list of all global variables and values?

571 views
Skip to first unread message

Hippo Man

unread,
May 13, 2015, 4:42:28 PM5/13/15
to tas...@googlegroups.com
Is there a way I can get a real-time list of all of Tasker's global variables and their current values?

I know I can see this info for _my_ global variables in the VARS tab, but I'm talking about programmatically getting a list of all global variables, both mine and Tasker's, and their current values. I'd like to be able to display this list in some sort of scene or app.

A key feature is that I don't want to have to know the names of all these variables in advance. I just want the list of all of them, whatever they might be named.

As an enhancement, I'd like to apply a filter to this list to only obtain the info about global variables whose names match some sort of regex, as well as optionally filtering by my variables versus Tasker's variables.

If I could get the complete list with an indication of whether any given variable is Tasker's or mine, I could write the filtering logic, myself.

Any ideas about how I could get that complete list?

Thank you in advance.
.

Juergen Gruen

unread,
May 14, 2015, 3:46:42 AM5/14/15
to tas...@googlegroups.com
Hi, you can get your own variables with Action-Tasker-TestTasker, Type: Global Variables. I do not think, that you can get a list of the build in variables.

Juergen.

Hippo Man

unread,
May 14, 2015, 5:04:33 PM5/14/15
to tas...@googlegroups.com
On Thursday, May 14, 2015 at 3:46:42 AM UTC-4, Juergen Gruen wrote:
Hi, you can get your own variables with Action-Tasker-TestTasker, Type: Global Variables. I do not think, that you can get a list of the build in variables

Oh. OK. Thank you.

I guess maybe I will try to write a plugin to get the Tasker variables.
.
 

Pent

unread,
May 15, 2015, 1:48:53 AM5/15/15
to tas...@googlegroups.com, hippoma...@gmail.com
There's a complete list of the builtin global variable names in the Variables section of the userguide.

Pent

Hippo Man

unread,
May 15, 2015, 4:07:46 AM5/15/15
to tas...@googlegroups.com, hippoma...@gmail.com
On Friday, May 15, 2015 at 1:48:53 AM UTC-4, Pent wrote:
There's a complete list of the builtin global variable names in the Variables section of the userguide.
 
I know. But I'm talking about programmatically getting that list from within Tasker, in real time.
.

Pent

unread,
May 15, 2015, 4:55:49 AM5/15/15
to tas...@googlegroups.com, hippoma...@gmail.com

There's a complete list of the builtin global variable names in the Variables section of the userguide.
 
I know. But I'm talking about programmatically getting that list from within Tasker, in real time.

The 'real' programmatic list will be identical to the web page list until variables are added/removed.
You can't get the list programatically in any case, so it's the only option.

Pent

Paul Vanderperren

unread,
May 15, 2015, 9:41:36 AM5/15/15
to tas...@googlegroups.com
Pent, the OP was after the vars AND THEIR CURRENT VALUES ...

Juergen Gruen

unread,
May 15, 2015, 9:52:57 AM5/15/15
to tas...@googlegroups.com
Getting the values is no problem if you have the names...

Hippo Man

unread,
May 15, 2015, 10:01:59 PM5/15/15
to tas...@googlegroups.com
On Friday, May 15, 2015 at 9:52:57 AM UTC-4, Juergen Gruen wrote:
Getting the values is no problem if you have the names...

Yep, and I see now (thank you, Pent) that there is no way to programmatically get the names of the Tasker globals.

... at least not from within Tasker contexts, tasks, or actions.

But what about from within a plugin? I've always wanted to write one.
.

Martin gigli

unread,
May 16, 2015, 9:26:06 AM5/16/15
to tas...@googlegroups.com
i use two options, the first it's more static but i use it when i want so see haw the variables are writen, i send them to a file (txt) each time that i need. The second it's more dinamic but you must limit the number of variables so you can see them on your screen, for this i use zooper

Juergen Gruen

unread,
May 21, 2015, 3:14:50 AM5/21/15
to tas...@googlegroups.com
Hi, this JavaScript filters the names of the global Variables from the Userguide:

/*
* DOMParser HTML extension
* 2012-09-04
*
* By Eli Grey, http://eligrey.com
* Public domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/

 
/*! @source https://gist.github.com/1129031 */
/*global document, DOMParser*/
 
(function(DOMParser) {  
   
"use strict";  
   
var DOMParser_proto = DOMParser.prototype  
     
, real_parseFromString = DOMParser_proto.parseFromString;

   
// Firefox/Opera/IE throw errors on unsupported types  
   
try {  
       
// WebKit returns null on unsupported types  
       
if ((new DOMParser).parseFromString("", "text/html")) {  
           
// text/html parsing is natively supported  
           
return;  
       
}  
   
} catch (ex) {}  

   
DOMParser_proto.parseFromString = function(markup, type) {  
       
if (/^\s*text\/html\s*(?:;|$)/i.test(type)) {  
           
var doc = document.implementation.createHTMLDocument("")
             
, doc_elt = doc.documentElement
             
, first_elt;

            doc_elt
.innerHTML = markup;
            first_elt
= doc_elt.firstElementChild;

           
if (doc_elt.childElementCount === 1
               
&& first_elt.localName.toLowerCase() === "html") {  
                doc
.replaceChild(first_elt, doc_elt);  
           
}  

           
return doc;  
       
} else {  
           
return real_parseFromString.apply(this, arguments);  
       
}  
   
};  
}(DOMParser));
/* END of DOMParser HTML extension */




/**********************************************************************/

function filterGlobalVars(data) {
   
var list = [];
   
var match = [];
   
var regex = /(%[A-Z]+)/g;

   
try {
   
   
var parser = new DOMParser();
       
var doc = parser.parseFromString(data, 'text/html');
   
       
       
var nlist = doc.getElementsByTagName("I");

       
for (i = 0; i < nlist.length; i++) {

            text
= nlist[i].innerText;
           
while ((match = regex.exec(text)) != null) {
                list
.push(match[0]);
           
}
       
}
   
} catch (e) {
       
return e.message;
   
}
   
   
return list;
}


/**********************************************************************/

function getHttp() {
   
var http = new XMLHttpRequest();
   
var url = "http://tasker.dinglisch.net/userguide/en/variables.html"
    http
.open("GET", url, false);
    http
.send();

   
if (http.status = 200) {
       
return (http.responseText);
   
}
   
else {
       
return false;
   
}

}


/**********************************************************************/

// main
var data = getHttp();
var list = filterGlobalVars(data);

Maybe this helps someone...

Juergen.

Hippo Man

unread,
May 21, 2015, 5:07:30 AM5/21/15
to tas...@googlegroups.com
On Thursday, May 21, 2015 at 3:14:50 AM UTC-4, Juergen Gruen wrote:
Hi, this JavaScript filters the names of the global Variables from the Userguide:

[ ... ]
Maybe this helps someone...

Juergen.

Wow! That's a lot more work than necessary on your part. Thank you for your effort!

I had mostly given up on wanting to get this variable info in real-time out of Tasker, itself, and I was thinking about web-scraping, in order to obtain it. You saved me a lot of time.
.


Juergen Gruen

unread,
May 21, 2015, 5:21:54 AM5/21/15
to tas...@googlegroups.com
You're welcome.

Hopefully Pent doesn't change the HTML structure of the website tomorrow ;-)

Reply all
Reply to author
Forward
0 new messages