-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjscript.cmd
99 lines (31 loc) · 1.36 KB
/
jscript.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@echo off
/* 2>nul:
rem Copyright 2015 Sajon Oso
rem This batch file runs the Windows Scripting Host (WSH) and executes the source file passed as the first argument
rem The embedded script loads a library file (jual_compat.js) which will make the WSH engine compatible with JualScript
rem This compatibility script can be modified for other javascript engines as well like NodeJS.
set JSCRIPTOUT=tmp.jsz
echo /* > %JSCRIPTOUT%
type %~f0 >> %JSCRIPTOUT%
set TARGETSCRIPT=NUL
if EXIST %1 set TARGETSCRIPT=%1
if NOT %TARGETSCRIPT%==NUL (
type %TARGETSCRIPT% >> %JSCRIPTOUT%
cscript /nologo /E:jscript %JSCRIPTOUT% %*
rem del %JSCRIPTOUT%
)
goto :eof
*/
// ## define function to load a library
function includeJS (filename) {
var fso = new ActiveXObject ("Scripting.FileSystemObject");
if (!fso.FileExists(filename)) filename = "../" + filename;
if (!fso.FileExists(filename)) filename = "../bin/" + filename;
var fileStream = fso.openTextFile (filename);
var fileData = fileStream.readAll();
fileStream.Close();
return fileData;
}
eval(includeJS("jscript2jual.js"));
// To help debug code when running jscript with this wrapper file, simply subtract the reported error line number by 100
// For the calculation to work this line should be line 99 with a terminating new line character.