diff --git a/exec/load/xjs.js b/exec/load/xjs.js index a1244befc206bc9cce4c36a420385346850cb272..46f05e92e33be87f381d0ff407173f569811529d 100644 --- a/exec/load/xjs.js +++ b/exec/load/xjs.js @@ -1,5 +1,5 @@ function xjs_compile(filename) { - if(cwd != '') { + if(typeof cwd == 'string' && cwd != '') { if(filename.search(/^((\/)|([A-Za-z]:[\/\\]))/)==-1) filename=cwd+filename; } @@ -91,3 +91,29 @@ function xjs_compile(filename) { } return(ssjs_filename); } + +function xjs_eval(filename, str) { + const ssjs = xjs_compile(filename); + const f = new File(filename + '.html'); + if (!f.open('w+', false)) { + log(LOG_ERR, "!ERROR " + f.error + " creating " + f.name); + return ''; + } + function write(s) { + f.write(s); + } + function writeln(s) { + f.writeln(s); + } + load(ssjs); + if (str) { + f.rewind(); + const ret = f.read(); + f.close(); + f.remove(); + return ret; + } else { + f.close(); + return filename + '.html'; + } +} \ No newline at end of file