Export (0) Print
Expand All

SkipLine Method (Windows Script Host)

Skips the next line when reading from an input text stream.

                      object.SkipLine

object

StdIn text stream object.

A line is a sequence of characters that ends with a newline character. 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. The position pointer moves forward to the point just past the next newline character. You cannot use the SkipLine method to skip backwards through a file. The SkipLine method is limited to the open for reading mode only (you cannot skip lines when writing to an output stream).

The following code demonstrates the SkipLine method.

Dim StdIn, StdOut, Str1, Str2

Set StdIn = WScript.StdIn
Set StdOut = WScript.StdOut

Str1 = ""
Str2 = ""

For i = 0 to 4 
   StdIn.SkipLine
Next

i = 0
Do While Not StdIn.AtEndOfStream
     If i >= 2 Then
          StdOut.WriteLine Str1
     End If
     i = i + 1
     Str1 = Str2
     Str2 = StdIn.ReadLine
Loop
var stdin = WScript.StdIn;
var stdout = WScript.StdOut;
var str1, str2 = "";
var i;
for (i = 0; i < 5; i++)
     stdin.SkipLine();
i = 0;
while (!stdin.AtEndOfStream)
{
     if (i++ >= 2)
     {
          stdout.WriteLine(str1);
     }
     str1 = str2;
     str2 = stdin.ReadLine();
}

Community Additions

ADD
Show:
© 2014 Microsoft