Javascript File Skip Method of textstream object provided by the FileSystemObject (FSO) performs the action of skipping the characters. Textstream object’s File Skip method skips the specified number of characters starting from the current position of the pointer of textstream. Initially it starts skipping from the first character of first column of first line of specified text file. Read methods of textstream object continues reading from the cursor position reached after the skip method.
Syntax for Javascript FSO textstream File Skip method
textStreamObj.Skip( Ncharacters );
Skip method of textstream object accepts only 1 parameter Ncharacters of integer type. Ncharacters accepts the integer value that specifies the number of characters to be skipped from the textstream of text specified file.
Example of FSO textstream File Skip Method
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// Open the text file at the specified location with write mode
var txtFile = fso.OpenTextFile("C:\\Temp\\myFolder\\file.txt", 2, false, 0);
txtFile.WriteLine("Hello this is the first line of text file.");
txtFile.WriteLine("Hello this is the second line of text file.");
txtFile.WriteLine("Hello this is the third line of text file.");
txtFile.Close();
// Open the text file at the specified location with read mode
txtFile = fso.OpenTextFile("C:\\Temp\\myFolder\\file.txt", 1, false, 0);
// reads 1 line at a time from the specified file and returns the result as string
var fText = txtFile.ReadLine();
document.write("<b>Original text:</b> <pre>" + fText + "</pre>");
// close the open textstream object file
txtFile.Close();
// Open the text file at the specified location with read mode
txtFile = fso.OpenTextFile("C:\\Temp\\myFolder\\file.txt", 1, false, 0);
fText = "";
// skips the specified number of characters
txtFile.Skip(10);
fText = txtFile.ReadLine();
document.write("<b>Text with skipped characters:</b> <pre>" + fText + "</pre>");
// close the open textstream object file
txtFile.Close();
fso = null
// Output:
// Original text:
// Hello this is the first line of text file.
// Text with skipped characters:
// is the first line of text file.
</script>
Continue to next tutorial: Javascript FSO textstream File SkipLine Method to learn how to skip a line from a loaded textstream.