Name
ReadLine (TextStream Object) —
tsObj
.ReadLine
Synopsis
The ReadLine method is similar to the Read method of the TextStream object in that it allows you to read from a text file into a string variable or compare the results of such a read to another entity. However, unlike the Read method, which uses an argument to determine how many characters to read, the ReadLine method reads all characters from the current pointer location to the next newline character.
Parameters
None
Example
<%
' Dimension local variables.
Dim fsoObject ' FileSystemObject
Dim filObject ' File Object
Dim tsObject ' TextStream object
Dim strBuffer ' Holding buffer
' Declare file access constants.
Const ForReading = 1
Const TristateFalse = 0
' Instantiate the FileSystemObject variable.
Set fsoObject = Server.CreateObject( _
"Scripting.FileSystemObject")
' Using the GetFile method of fsoObject, initialize the
' File object.
Set filObject = fsoObject.GetFile("d:\docs\test.txt")
' Use the OpenAsTextStream method to open the file for
' reading and in ASCII format.
Set tsObject = filObject.OpenAsTextStream(ForReading, TristateFalse)
' Use the ReadLine method to read the next line of text
' from the text file into the strBuffer variable.
strBuffer = tsObject.ReadLine
%>Notes
After calling the ReadLine method, the current location of the pointer within the file is the character immediately after the last newline character or at the end of file marker.
Note that you must explicitly declare constants for use with the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access