Javascript & performTask (%par1 and %par2 problems)

392 views
Skip to first unread message

kitze

unread,
Jan 9, 2014, 7:35:38 PM1/9/14
to tas...@googlegroups.com
Finally the "include jQuery" bug is fixed in the latest beta, and now i can finally execute performTask from a javascript file, but the %pars are going nuts!

I lost ~2 hours hunting "my" bug but it looks like Tasker has some problems with parameters and sometimes it doesn't pass them.

I'm trying

function simulatePerformTask(stringOne, stringTwo){
           alert(stringTwo);
           flash(stringTwo);
           performTask("Testing paremeters", 10, stringOne, stringTwo);
}

and alert alerts the string but flash says that the second parameter is "undefined".

What could be the problem?

Thanks!

kitze

unread,
Jan 9, 2014, 8:19:32 PM1/9/14
to tas...@googlegroups.com
I found the bug i think, this only happens when i'm using a String.prototype, i have few of them declared in the beginning of my js file, and the script is fine until i use some of them on a string. Then the string becomes "undefined" for Tasker, but how the hell does it display it in an "alert" but not in a "flash"? It's really weird...

Pent

unread,
Jan 10, 2014, 1:45:41 AM1/10/14
to tas...@googlegroups.com

I found the bug i think, this only happens when i'm using a String.prototype,

What's that ? I'm not a JS programmer.
 
i have few of them declared in the beginning of my js file, and the script is fine until i use some of them on a string. Then the string becomes "undefined" for Tasker, but how the hell does it display it in an "alert" but not in a "flash"? It's really weird...

Probably because alert is initially handled by the JS engine.

Pent

kitze

unread,
Jan 10, 2014, 3:51:14 AM1/10/14
to tas...@googlegroups.com
String.prototype is when you modify the JavaScript String object to add more functions to it, for example

String.prototype.replaceWordWithKitty = function(word){
           return this.replace(word, "kitty");
}
var sentence = " hello what are you doing";
sentence = sentence.replaceWordWithKitty("hello");

This will make replace the word "hello" with "kitty" in the sentence var.

Danielo515

unread,
Mar 5, 2015, 7:15:18 AM3/5/15
to tas...@googlegroups.com
Hello,

Do you know if it is possible to access a task parameters from JS? I'm asking here because looks like you have fought with it.

Odysseos

unread,
Mar 10, 2015, 4:39:19 AM3/10/15
to tas...@googlegroups.com
I think you must use in your javascript code something like this:

var a = par[0]
var b = par[1]

where par[0] and par[1] are the variables %par1 and %par respectively (remember that in javascript "counting" starts from 0).

Danielo515

unread,
Mar 13, 2015, 10:15:05 AM3/13/15
to tas...@googlegroups.com
Yes! Exactly. Thank you. I'm skilled at javascript, but not in Tasker. I did not know that task parameters were arrays. Thanks again
Reply all
Reply to author
Forward
0 new messages