Logic Machine Forum
Run script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Run script (/showthread.php?tid=2579)



Run script - JMM - 14.04.2020

Hi,

I would like to be able to force the execution of a Scheduled Script, is there a solution for that ?

If blablabla then
  Scheduled_script > run
end

BR
Jean-Marc


RE: Run script - Joep - 14.04.2020

script.enable(Script_Name)

and

script.disable(Script_Name)


RE: Run script - admin - 14.04.2020

enable does not execute the scheduled script. One solution is to create a user library and move your code there. Then run it by calling require from scheduled and any other script. Make sure that auto load is disabled for this library.


RE: Run script - JMM - 14.04.2020

(14.04.2020, 08:51)admin Wrote: enable does not execute the scheduled script. One solution is to create a user library and move your code there. Then run it by calling require from scheduled and any other script. Make sure that auto load is disabled for this library.
Thanks admin.
This is what I am currently doing but it does not exactly meet my needs...


RE: Run script - admin - 14.04.2020

Can you explain why this solution doesn't fit your needs?


RE: Run script - JMM - 14.04.2020

(14.04.2020, 10:19)admin Wrote: Can you explain why this solution doesn't fit your needs?
Sorry, I confused Common function and user library

Can you tell me what is the procedure to call a user script from other script ?

Jean-Marc


RE: Run script - admin - 14.04.2020

Just use require('user.user_lib_name') in your code. Keep in mind that if you require the same library multiple times it will be executed only the first time. If you need to call it multiple times then you need to wrap your code into a function and then call this function. It's also good practice to use local variables in your library otherwise variables with same name in your main script will be overwritten.


RE: Run script - JMM - 14.04.2020

(14.04.2020, 15:26)admin Wrote: Just use require('user.user_lib_name') in your code. Keep in mind that if you require the same library multiple times it will be executed only the first time. If you need to call it multiple times then you need to wrap your code into a function and then call this function. It's also good practice to use local variables in your library otherwise variables with same name in your main script will be overwritten.
Thanks Admin ! Good.