There is a way to know if a script is still running?

There is a way to know if a script is still running?

Let me explain better…

I have this kind of script:

//start—

var script=LL.getScriptByName(“name”);

script.setTag(“something”,something)

LL.runScript(“name”,0);

/in the other script i do something and then i set a tag on that script/

var value=script.getTag(“otherthing”);

//do something with value

//end—

the other script takes time to do all its calculations and in the meanwhile the current script has already taken the tag from that script.

In this way the current script takes always the tag of the precedent execution!

That’s why i need to know if the other script is still running.

P.S. i already tried to use JSON for a faster data passing, but nothing has changed…

]]>

12 Commentsto There is a way to know if a script is still running?

  1. Anonymous says:

    < ![CDATA[

    First: runScript will run the script always when the current script finishes. No matter how fast that script is, the tag will be always the old one.



    You can instead use eval(script.getText()) but you can’t pass parameters and alerts and such won’t work (although you can with a little trick)



    What exactly does the other script? Perhaps we can suggest a better way

    ]]>

  2. Anonymous says:

    < ![CDATA[

    The other script get a tag setted on itself and it use that tag as parameter of the function that i posted in the previous post(color_shade).


    Then the returned value is used to set another tag always on itself.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    So, you can simply do:



    In the ‘library’ script have only defined functions



    function a(x){


    return y;


    }


    function b(){


    }



    Then in any script simply run eval(LL.getScriptByName(“name”));



    Now you can use the functions as usual


    alert(a(5));


    b();

    ]]>

  4. Anonymous says:

    < ![CDATA[

    In this way the script is used as a library of functions!! So coooooool!!!! O.O


    But do eval() require something as object?


    LL.eval()?

    ]]>

  5. Anonymous says:

    < ![CDATA[

    No, it is a JavaScript native function.


    It will evaluate the string passed as a JavaScript code. But no alert/prompt/confirm can be run (although, as I said, there is a little trick to do that)



    I’m using it in my fastRunTool 🙂

    ]]>

  6. Anonymous says:

    < ![CDATA[

    You intrigued me. Can you explain in what consist that “trick”?

    ]]>

  7. Anonymous says:

    < ![CDATA[

    http://www.pierrox.net/android/applications/lightning_launcher/script/reference/net/pierrox/lightning_launcher/script/api/Script.html



    I wasn’t technically right on my answer. You can use alert inside the functions from the library. But you can’t use alert when executing directly the code.



    eval(“alert(“no”)”);



    eval(“function aFunction(){eval(‘yes’);}”)


    aFunction();

    ]]>

  8. Anonymous says:

    < ![CDATA[

    I understand 🙂


    anyway now i’m trying eval() and modifying some other things in the codes.


    I’ll let you know if it works correctly.

    ]]>

  9. Anonymous says:

    < ![CDATA[

    it doesn’t work xD 


    The script that contains the function is called “Palette” and there is only the color_shader() function inside.


    In another script i did like this:


    eval(LL.getScriptByName(“Palette”));


    var something=color_shader(color, some_value);



    but it says that color_shader() is not defined >.<

    ]]>

  10. Anonymous says:

    < ![CDATA[

    TrianguloY I solved the problem:


    I had a look to a your previous comment and I correct the eval() method -> eval(LL.getScriptByName(“Palette”).getText());

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Question to TrianguloY: I have a ‘library-script’ but bind my functions to self like: self.functionA. This way I only have to load it once in desktop-load-event, if I need them in more places. Down-side is de data/functions attached to self seem to be the first to get lost with low memory (or something).


    The question: what do you think of this method instead of the eval(library)? Which method would need more memory? or recources?

    ]]>

  12. Anonymous says:

    < ![CDATA[

    Errr that’s more a Pierre Hébert​​’s question and how the scripts context is managed.


    Technically your method need less memory and resources, as your functions are always there and don’t need to be parsed/loaded each time (even thought they are kept in memory, but I don’t think it costs too much). The problem as you said is that you can’t be really sure if they are still there/loaded (again Pierre Hébert​​ can explain this) so the eval method ensures that they are always ready to use.



    Maybe the best method is a mix of both adding this at the top of every script



    if(self.loaded==undefined)eval(LL.getScriptByName(“library”).getText());



    Where the library script binds the functions to self, including a (whatever) value into self.loaded

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *