views:

620

answers:

2

If I have a cscript that outputs lines tothe 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
+2  A: 

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.

Tomalak
Yes, wscript.print is right - regressed to my old VB script days...I'm sure you know you can "echo" command characters to the console and this is how you wrote the old "DOS" style applications. Can this still be done to manipulate the cursor?
Guy
@Guy: VBScript's `WScript.Print()` works like VB6's `Debug.Print()` in regard to newlines, so... no, not to my knowledge.
Tomalak
+2  A: 

Use wscript.stdout.write() instead of print.

naivnomore
oops - regredded to my VB days. Yes, WScript.Print is the correct command!
Guy
I meant you could use wscript.stdout.write instead of wscript.print to print on the same line without the new line characters.
naivnomore
Yep - That will work!!!
Guy