Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cscript - print output on same line on console?

If I have a cscript that outputs lines to the screen, how do I avoid the "line feed" after each print?

Example:

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

The expected output should be:

..........

Not:

.
.  
.
.
.
.
.
.
.
.

In the past I've used to print the "up arrow character" ASCII code. Can this be done in cscript?

ANSWER

Print on the same line, without the extra CR/LF

for a=1 to 15
  wscript.stdout.write a
  wscript.stdout.write chr(13)
  wscript.sleep 200
next
like image 975
Guy Avatar asked May 24 '10 14:05

Guy


2 Answers

Use WScript.StdOut.Write() instead of WScript.Print().

like image 195
naivnomore Avatar answered Oct 16 '22 16:10

naivnomore


WScript.Print() prints a line, and you cannot change that. If you want to have more than one thing on that line, build a string and print that.

Dim s: s = ""

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

print s

Just to put that straight, cscript.exe is just the command line interface for the Windows Script Host, and VBScript is the language.

like image 29
Tomalak Avatar answered Oct 16 '22 18:10

Tomalak