However, the documentation is, quite frankly, crap. Can someone post some example code that reads in a line of text, calls
foo(string) on it, and echos the output to the command line?
Similarly, how do I actually run it? Will
wscript.exe PATH_TO_JS_FILE do the trick?
If you’re using the command-line, I’d execute the script using
This is because
WSCRIPT will create a dialog box and from
CSCRIPT outputs a line to the console. Run this in a command window (CMD).
Reading a line from console into variable:
var x = WScript.StdIn.ReadLine();
StdIn is a TextStream object. There is also an
StdOut which can be used in place of
Writing the output of
foo(x) to console: (must run under
You can use the
WScript object to determine which engine you are running under, there’s a question/answer for that (VBScript, but uses the same objects under JScript) here.