11

画面に行を出力するcscriptがある場合、各印刷後に「改行」を回避するにはどうすればよいですか?

例:

for a = 1 to 10
  WScript.Print "."
  REM (do something)
next

期待される出力は次のとおりです。

..........

いいえ:

.
.  
.
.
.
.
.
.
.
.

以前は、「上矢印文字」のASCIIコードを印刷していました。これはcscriptで実行できますか?

答え

余分なCR/LFなしで、同じ行に印刷します

for a=1 to 15
  wscript.stdout.write a
  wscript.stdout.write chr(13)
  wscript.sleep 200
next
4

3 に答える 3

14

WScript.StdOut.Write()の代わりに使用しWScript.Print()ます。

于 2010-05-24T14:48:09.443 に答える
2

WScript.Print()行を印刷しますが、変更することはできません。その行に複数のものを入れたい場合は、文字列を作成して印刷します。

Dim s: s = ""

for a = 1 to 10
  s = s & "."
  REM (do something)
next

print s

簡単に言うと、cscript.exeこれはWindows Script Hostのコマンドラインインターフェイスであり、VBScriptが言語です。

于 2010-05-24T14:36:41.590 に答える
-1

JavaScript で次の「ログ」関数を使用して、wscript または cscript 環境をサポートしています。ご覧のとおり、この関数は可能な場合にのみ標準出力に書き込みます。

var ExampleApp = {
    // Log output to console if available.
    //      NOTE: Script file has to be executed using "cscript.exe" for this to work.
    log: function (text) {
        try {
            // Test if stdout is working.
            WScript.stdout.WriteLine(text);
            // stdout is working, reset this function to always output to stdout.
            this.log = function (text) { WScript.stdout.WriteLine(text); };
        } catch (er) {
            // stdout is not working, reset this function to do nothing.
            this.log = function () { };
        }
    },
    Main: function () {
        this.log("Hello world.");
        this.log("Life is good.");
    }
};

ExampleApp.Main();
于 2012-12-03T17:44:50.333 に答える