Converting the Windows Script Host SkipLine Method

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

SkipLine

We have to tell you the truth: we’re not totally sure what you would use SkipLine for. SkipLine is designed to skip a line of input, which is great except for one thing: it’s used primarily when working with StdIn, and in Windows Script Host you can only input one line of data at a time; as soon as you press the ENTER key data input is complete. You actually can call SkipLine and it actually will skip the line just entered; because that’s the only line entered, however, that means it throws away all the data the user just typed in. Tempting, we know. But not very practical.

To show how desperate we were to find a use for this method we even looked in the Windows Script Host language reference. We found a sample script there that uses SkipLine, but all that sample script does is lock us up in an endless loop. Intriguing, we know. But not very practical.

Heck, even our very own Microsoft Windows 2000 Scripting Guide mentions the SkipLine method without bothering to show an example of how it works.

In other words, we have no idea what SkipLine is really for, which means we have no idea how to do that same thing (whatever it is) in Windows PowerShell. We did uncover one script that repeatedly prompted a user to enter a value, and used SkipLine to reinitialize the input variable. That actually worked, but it seemed like an odd way to do data entry, so we aren’t even going to bother with it. If you want to repeatedly request user input in Windows PowerShell you can use a script like this one instead:

for ($i = 1; $i -lt 5; $i++)
    {$a = Read-Host "Please enter your name"; $a}

See conversions of other Windows Script Host methods and properties.
Return to the VBScript to Windows PowerShell home page