How can I write a simple JScript input/output program?

前端 未结 2 1277
梦毁少年i
梦毁少年i 2021-01-02 09:46

I\'m planning on using JavaScript to enter an informatics competition (BIO) tomorrow. However, I can\'t rely on the examiner having a browser with a decent JavaScript engine

2条回答
  •  既然无缘
    2021-01-02 10:31

    If you want to be sure your program only runs in the command line, you may use the WScript.StdIn and WScript.StdOut objects/properties:

    var myString = WScript.StdIn.ReadLine();
    WScript.StdOut.WriteLine(myString);
    

    and run it with cscript.exe. But if you want it to be a GUI program, it is a bit more difficult considering that JScript doesn't have a native InputBox function like VBScript. However, as described here we may use Windows Script Host (WSH). Create a .wsf file:

    
    
        
    
        
    
    

    and run it with either cscript.exe or wscript.exe. Alternatively, you could also use HTML Application (HTA) to create more elaborate GUIs.

提交回复
热议问题