11.3 TextStream

The TextStream facilitates sequential access to a file.

11.3.1 AtEndOfLine property

Returns TRUE if the file pointer immediately precedes the end-of-line marker in a TextStream file.

Syntax

 object.AtEndOfLine
 

Type

Boolean.

Attributes

Read-only.

Example

See sample in Example

11.3.2 AtEndOfStream property

Returns TRUE if the file pointer is at the end of a TextStream file.

Syntax

 object.AtEndOfStream
 

Type

Boolean.

Attributes

Read-only.

Example

This example TRUE if the file pointer is at the end of the textstream in file TEST.TXT.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
 Set TextStream = FSO.opentextfile("sys:nsn\user\test.txt")
 Do while (TextStream.AtEndOfStream = FALSE)
     Response.Write TextStream.Readline
 Loop
 Textstream.Close %>
 

11.3.3 Column property

Returns the column number of the current character position in a TextStream file.

Syntax

 object.Column
 

Type

Integer.

Attributes

Read-only.

Example

This example opens a text file and returns the position of the file pointer.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
 Set Textstream = FSO.opentextfile("sys:nsn\user\profit.txt")
 Response.Write TextStream.Column
 Textstream.Read (5)
 Response.Write Textstream.Column
 Textstream.Close %>
 

See Also

11.3.4 Line property

Returns the current line number in a TextStream file.

Syntax

 object.Line
 

Type

Long.

Attributes

Read-only.

Example

This example returns a number, which is line where the file pointer is placed.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
 Set Textstream = FSO.opentextfile("sys:nsn\user\profit.txt")
 Response.Write TextStream.Line 
 Textstream.close() %>
 

11.3.5 Close method

Closes an open TextStream file.

Syntax

 object.Close
 

Parameters

None.

Return Value

Boolean.

Example

See sample in Example.

See Also

11.3.6 Read method

Reads a specified number of characters from a TextStream file and returns the resulting string.

Syntax

 object.Read(
    Character As Long)
 

Parameters

Character
Number of the characters to be read.

Return Value

String.

Example

See sample in Example.

11.3.7 ReadAll method

Reads an entire TextStream file and returns the resulting string.

Syntax

 object.ReadAll
 

Parameters

None.

Return Value

String.

Remarks

The maximum size of the returned string is 10 KB.

Example

This example returns TEST.TXT.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
 Set Textstream = FSO.OpenTextFile("sys:nsn\user\test.txt")
 Response.Write TextStream.ReadAll()
 Textstream.close() %>
 

11.3.8 ReadLine method

Reads an entire line (excluding the newline character) where the pointer is present in a TextStream file and returns the resulting string.

Syntax

 object.ReadLine
 

Parameters

None.

Return Value

String.

Example

See sample in Example.

11.3.9 Skip method

Skips a specified number of characters when reading a TextStream file.

Syntax

 object.Skip(
    Character As Long)
 

Parameters

Character
Number of character to skip while reading a file.

Return Value

Void.

Example

The file pointer will be placed after 10 characters in the textstream PROFIT.TXT.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
 Set Textstream = FSO.OpenTextFile("sys:nsn\user\test.txt")
 Response.Write TextStream.Skip (10)
 Textstream.close() %> 
 

See Also

11.3.10 SkipLine method

Skips to the next line while reading a TextStream file.

Syntax

 object.SkipLine
 

Parameters

None.

Return Value

Void.

Example

The file pointer is placed in the next line w.r.t to the current position in the textstream PROFIT.TXT.

 <% Set FSO = CreateObject("Scripting.FileSystemObject")
 Set Textstream = FSO.OpenTextFile("sys:nsn\user\test.txt")
 Response.Write TextStream.SkipLine()
 Textstream.close() %>
 

See Also

11.3.11 Write method

Writes a specified string from the position where the pointer is placed in a TextStream file.

Syntax

 object.Write(
    Text As Variant)
 

Parameters

Text
Text string you want to write to the file.

Return Value

Boolean.

11.3.12 WriteLine method

Writes a specified string and a newline character from the position where the pointer is placed in a TextStream file.

Syntax

 object.WriteLine([
    Text As Variant])
 

Parameters

Text
Text you want to write to the file. If omitted, a newline character is written to the file.

Return Value

Boolean.

11.3.13 WriteBlankLines method

Writes a specified number of newline characters at the position where the pointer is placed in a TextStream file.

Syntax

 object.WriteBlankLines(
    Lines As Long)
 

Parameters

Lines
Number of newline characters you want to write to the file.

Return Value

Boolean.