1
Solved

Allow tasker variable in definition of JavaScriptlet.

As an example, to find the distance between London and New York, I'd like to:

    Wanted (52)
        A1: Read File [ File:Tasker/javascript/geo/distance.js To Var:%jsdistance ] 
        A2: Variable Set [ Name:%distance To:%jsdistance
    var dis = jsprivate_gcdistance('km', 51.5286417, -0.1015986, 40.6974881, -73.979681); Recurse Variables:Off Do Maths:Off Append:On Max Rounding Digits:3 ] 
        A3: JavaScriptlet [ Code:%distance Libraries: Auto Exit:On Timeout (Seconds):45 ] 
        A4: Flash [ Text:The distance between London and New York is %dis km. Long:Off ] 
    

But the definition of the code has to be a literal. The work round is:

    Have To (96)
        A1: Read File [ File:Tasker/javascript/geo/distance.js To Var:%jsdistance ] 
        A2: Variable Set [ Name:%distance To:%jsdistance
    var dis = jsprivate_gcdistance('km', 51.5286417, -0.1015986, 40.6974881, -73.979681); Recurse Variables:Off Do Maths:Off Append:On Max Rounding Digits:3 ] 
        A3: Write File [ File:Tasker/javascript/temp Text:%distance Append:Off Add Newline:On ] 
        A4: JavaScript [ Path:Tasker/javascript/temp Libraries: Auto Exit:On Timeout (Seconds):45 ] 
        A5: Flash [ Text:The distance between London and New York is %dis km. Long:Off ] 
    

1 reply

Can you please try this version and use eval() to run the script?

https://drive.google.com/file/d/1UfMEt1H6wjlMDdsqByn-flCRqE45PdJ1/view?usp=sharing

Topic is closed for comments