New ScreenPanel
This commit is contained in:
31
script/tstrun.js
Executable file
31
script/tstrun.js
Executable file
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
|
||||
|
||||
function run(script_name, args) {
|
||||
/*
|
||||
Run script: can be absolute path, relative, or short name to be search in the path.
|
||||
Args:
|
||||
args(Dict ot Array): gobal variables set to the script(if dict), or argv varialble (if array).
|
||||
|
||||
Returns:
|
||||
The script return value
|
||||
*/
|
||||
var script = get_context().scriptManager.library.resolveFile(script_name)
|
||||
var file = script!=null ? new File(script) : null
|
||||
if ((file == null) || ( ! file.exists())) throw "Invalid script: " + script_name
|
||||
get_context().startScriptExecution(args)
|
||||
|
||||
if (is_defined(args) && (args!=null)){
|
||||
if (is_array(args)){
|
||||
argv = args
|
||||
} else {
|
||||
for (var key in args) {
|
||||
eval(key+"="+args[key])
|
||||
}
|
||||
}
|
||||
}
|
||||
//eval(new String(Files.readAllBytes(file.toPath())))
|
||||
//get_context().scriptManager.interpreter.evalFile(script);
|
||||
load(script)
|
||||
}
|
||||
Reference in New Issue
Block a user