Windows Script Host  

ReadLine Method

Returns an entire line from an input stream.

object.ReadLine 

Arguments

object
StdIn text stream object.

Remarks

The ReadLine method returns a string. The StdIn, StdOut, and StdErr properties and methods work when running the script with the CScript.exe host executable file only. An error is returned when run with WScript.exe. A line is a sequence of characters that ends with a newline character.

Note   Although this method extracts the newline character, it does not add it to the string.

Example

The following code demonstrates the use of the ReadLine method.

[VBScript]
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
[JScript]
var stdin = WScript.StdIn;
var stdout = WScript.StdOut;

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

See Also

StdIn Property | FileSystemObject Object