Hi Manish,
I think the simplest method to execute a list of scripts is to use the load() command. We typically use it to load a library, which just contains function definitions, but if the loaded script files contain commands or function calls (i.e. something which directly runs), then they are executed in the order of the load commands.
load("one.js");load("two.js");load("three.js");
Does that help?
Happy scripting!
Nils
Manish has these follow-up questions:
With "conditional execution" you mean that a script is only executed in case of a certain condition to be fulfilled? Then you can use in your main script (using the load() methods) normal if statements as usual in Javascript. Just put the load() within the curly brackets of the if clause.
On the element marking, you probably mean the selection being active before the script is started (the one(s) on which the right click > Execute > ... was done). Also here this can be put into the main script around the load() calls. For details of handling selection, see for example here.
These requests give the impression that you are not only executing a list of existing scripts in order, but want to make a more complex script out of them. In that case I would recommend to put the functionality of the subscripts into (a) function(s) in their files (so that they are not automatically executed when loading the files) and calling these functions in the main script. So the load() calls go first, loading the original scripts as libraries, and then you can create your main script, without too many details, but calling the subfunctions from the other script (now library) files.
Happy scripting,
Hi Nils,
of course we do not know, how the scripts are structure - but let's assume the just contain functions f1, f2 or main.
In that case you can load them into a variable and then run one or multiple of the functions:
var script1 = load("~/script1.js");if(cond) script1.f1()else script1.f2()
for the second question probably the script needs to be adjusted and you need to open a selection dialog (with selectElement from ui.js).
Eckhardt
Hi Nils/Eckhardt,
I would try the solution provided by you.
Some of the scripts in the sequence need from user to say "yes or not" and we want to configure the selection dialog box input answer in the script which will run the sequence of scripts .
I will first give a try and come back to you.
Regards
Manish