Partager via


WriteLine Method (Windows Script Host)

Sends a string with a newline character to an output stream.

                      object.WriteLine([strText]) 

Arguments

  • object
    StdOut or StdErr text stream objects.

  • strText
    Optional. String value indicating the text you want to write to the stream. If omitted, a newline character is written to the output stream.

Remarks

The WriteLine method always appends a newline character to the string. Calling the WriteLine method without supplying the argument strText is equivalent to calling WriteBlankLines(1). The StdIn, StdOut, and StdErr properties and methods work when running the script with the CScript.exe host executable file only. An "Invalid Handle" error is returned when run with WScript.exe. A line is a sequence of characters that ends with a newline character.

Example

The following code demonstrates the WriteLine method.

Dim StdIn, StdOut
Set StdIn = WScript.StdIn
Set StdOut = WScript.StdOut

Do While Not StdIn.AtEndOfStream
     str = StdIn.ReadLine
     StdOut.WriteLine "Line " & (StdIn.Line - 1) & ": " & str
Loop
var stdin = WScript.StdIn;
var stdout = WScript.StdOut;

while (!stdin.AtEndOfStream)
{
     var str = stdin.ReadLine();
     stdout.WriteLine("Line " + (stdin.Line - 1) + ": " + str);
}

Applies To:

StdErr Property (WScript)| StdOut Property (WScript)

See Also

Reference

WriteBlankLines Method (Windows Script Host)

TextStream Object