Skip to content
Snippets Groups Projects
Commit 1f3b9383 authored by echicken's avatar echicken :chicken:
Browse files

Don't shit pants if 'cwd' isn't a thing or a string.

Added xjs_eval(filename, str)
- notionally for evaluating XJS without immediate write
- if str, returns the evaluated script as a string
- if !str, returns the filename that the script was dumped to
- was a fun idea, but doesn't play well with other scripts
- best used with simple and self-contained xjs
parent bde3b59e
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
function xjs_compile(filename) { function xjs_compile(filename) {
if(cwd != '') { if(typeof cwd == 'string' && cwd != '') {
if(filename.search(/^((\/)|([A-Za-z]:[\/\\]))/)==-1) if(filename.search(/^((\/)|([A-Za-z]:[\/\\]))/)==-1)
filename=cwd+filename; filename=cwd+filename;
} }
...@@ -91,3 +91,29 @@ function xjs_compile(filename) { ...@@ -91,3 +91,29 @@ function xjs_compile(filename) {
} }
return(ssjs_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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment