ÄúµÄλÖãº
Ñ°ÃÎÍøÊ×Ò³
£¾
±à³ÌÀÖÔ°
£¾
VBScript
£¾
VBScript
objects
constants
operators
statements
functions
properties
methods
All Objects
CreateObject Function
Dictionary Object
Err Object
FileSystemObject Object
OBJECT: TextStream
The
TextStream
object provides sequential access to the contents of any file where the contents are in text-readable form. You can create an instance of the
TextStream
object using the
CreateTextFile
or
OpenTextFile
methods of the
FileSystemObject
object, or alternatively by using the
OpenAsTextStream
method of the
File
object.
In the following code the
CreateTextFile
method is used on the
FileSystemObject
to return the
TextStream
object, "testfile". This
TextStream
object is then manipulated using the
WriteLine
and
Close
methods.
Code:
<%
Dim filesys, testfile
Set filesys = CreateObject("Scripting.FileSystemObject")
Set testfile= filesys.CreateTextFile("c:\somefile.txt", True)
testfile.WriteLine "Your text goes here."
testfile.Close
%>
Every instance of a
TextStream
object has an internal pointer that points to a specific place in the file. When first opening the stream, this pointer is positioned at the first character in the file. The pointer will then move around as you manipulate the
TextStream
object using it's methods and properties.
PROPERTIES
AtEndOfLine
Property
Returns a Boolean value. If the file pointer is positioned immediately before the file's end-of-line marker, the value is
True
, and
False
otherwise.
Syntax:
object.
AtEndOfLine
AtEndOfStream
Property
Returns a Boolean value. If the file pointer is positioned at the end of a file, the value is
True
, and
False
otherwise.
Syntax:
object.
AtEndOfStream
Column
Property
Returns the current position of the file pointer within the current line. Column 1 is the first character in each line.
Syntax:
object.
Column
Line
Property
This property returns the current line number in a text file.
Syntax:
object.
Line
METHODS
Close
Method
Closes a currently open
TextStream
file.
Syntax:
object.
Close
Read
Method
This method reads the number of characters you specify from a
Textstream
file and returns them as a string.
Syntax:
object.
Read
(characters)
ReadAll
Method
This method reads the entire contents of a text file and returns it as a string.
Syntax:
object.
ReadAll
ReadLine
Method
Reads a single line (excluding the newline character) from a
TextStream
file and returns the contents as a string.
Syntax:
object.
ReadLine
Skip
Method
Causes the file pointer to skip a specified number of characters when reading a
TextStream
file. Can be a positive or negative number.
Syntax:
object.
Skip
(characters)
SkipLine
Method
Moves the file pointer from it's current position to the beginning of the next line.
Syntax:
object.
SkipLine
Write
Method
This method writes a supplied string to an open
TextStream
file.
Syntax:
object.
Write
(string)
WriteLine
Method
Writes a supplied string to a
TextStream
file, followed by a new line character.
Syntax:
object.
WriteLine
([string])
WriteBlankLines
Method
Used to write a number of consecutive newline characters (defined with the
lines
parameter) to a
TextStream
file.
Syntax:
object.
WriteBlankLines
(lines)