3 <title>KOL Help: TStream object (main frame)
</title>
7 <body bgcolor=
"#FFFFEF" text=
"#000000" link=
"#008080" vlink=
"#008000" alink=
"#808000">
8 <p><font face=
"Courier" color=
"#800080"><b>TStream( unit
<a href=kol_pas.htm
>KOL.pas
</a> )
9 <font face=
"Wingdings">ï
</font> <a href=tobj.htm
>TObj
</a>
10 <font face=
"Wingdings">ï
</font> <a href=_tobj.htm
>_TObj
</a>
13 TStream = object(
<a href=tobj.htm
target=
"_top">TObj
</a> )
15 Simple stream object. Can be opened for file, or as memory stream (see
16 <a href=kol_pas.htm#newreadfilestream
target=
"_top">NewReadFileStream
</a>,
<a href=kol_pas.htm#newwritefilestream
target=
"_top">NewWriteFileStream
</a>,
<a href=kol_pas.htm#newmemorystream
target=
"_top">NewMemoryStream
</a>, etc.). And, another
17 type of streaming object can be derived (without inheriting new object
18 type, just by writing another New...Stream method, which calls
19 <a href=kol_pas.htm#_newstream
target=
"_top">_NewStream
</a> and pass methods record to it).
20 <h3 align=
"center"><font color=
"#FF8080">TStream properties
</font></h3>
23 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Size
</b></font>:
<b>DWord
</b>;
</font>
25 Returns stream size. For some custom streams, can be slow
26 operation, or even always return undefined value (-
1 recommended).
28 <a name=
"position"></a>
30 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Position
</b></font>:
<b>DWord
</b>;
</font>
36 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Memory
</b></font>:
<b>Pointer
</b>;
</font>
37 <font face=
"Webdings" size=
7>Ñ</font>
39 Only for memory stream.
43 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Handle
</b></font>: THandle;
</font>
44 <font face=
"Webdings" size=
7>Ñ</font>
46 Only for file stream. It is possible to check that Handle
<>
47 INVALID_HANDLE_VALUE to ensure that file stream is created OK.
49 <a name=
"methods"></a>
51 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Methods
</b></font>: PStreamMethods;
</font>
52 <font face=
"Webdings" size=
7>Ñ</font>
54 Pointer to TStreamMethods record. Useful to implement custom-defined
55 streams, which can access its fCustom field, or even to change
56 methods when necessary.
60 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Data
</b></font>: TStreamData;
</font>
61 <font face=
"Webdings" size=
7>Ñ</font>
63 Pointer to TStreamData record. Useful to implement custom-defined
64 streams, which can access Data fields directly when implemented.
66 <a name=
"capacity"></a>
68 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Capacity
</b></font>:
<b>DWORD
</b>;
</font>
70 Amound of memory allocated for data (MemoryStream).
72 <h4 align=
"center"><font color=
"black">Properties, inherited from
<a href=
"tobj.htm" target=
"_top">TObj
</a></font></h4>
73 <h3 align=
"center"><font color=
"#FF8080">TStream methods
</font></h3>
76 <font face=
"Courier" color=
"#800080"><b>function
</b> <b>Read
</b>(
<b>var
</b> Buffer; Count:
<b>DWord
</b> ):
<b>DWord
</b>;
</font>
78 Reads Count bytes from a stream. Returns number of bytes read.
82 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>Seek
</b></font>( MoveTo:
<b>Integer
</b>; MoveMethod: TMoveMethod ):
<b>DWord
</b>;
</font>
84 Allows to change current position or to obtain it. Property
85 <a href=#position
target=
"main">Position
</a> uses this method both for get and set position.
89 <font face=
"Courier" color=
"#800080"><b>function
</b> <b>Write
</b>(
<b>var
</b> Buffer; Count:
<b>DWord
</b> ):
<b>DWord
</b>;
</font>
91 Writes Count bytes from Buffer, starting from current position
92 in a stream. Returns how much bytes are written.
94 <a name=
"writestr"></a>
96 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>WriteStr
</b></font>( S:
<b>String
</b> ):
<b>DWORD
</b>;
</font>
98 Writes string to the stream, not including ending #
0. Exactly
99 Length( S ) characters are written.
101 <a name=
"writestrz"></a>
103 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>WriteStrZ
</b></font>( S:
<b>String
</b> ):
<b>DWORD
</b>;
</font>
105 Writes string, adding #
0. Number of bytes written is returned.
107 <a name=
"readstrz"></a>
109 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>ReadStrZ
</b></font>:
<b>String
</b>;
</font>
111 Reads string, finished by #
0. After reading, current position in
112 the stream is set to the byte, follows #
0.
114 <a name=
"readstr"></a>
116 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>ReadStr
</b></font>:
<b>String
</b>;
</font>
118 Reads string, finished by #
13, #
10 or #
13#
10 symbols. Terminating symbols
119 #
13 and/or #
10 are not added to the end of returned string though
120 stream positioned follow it.
122 <a name=
"writestrex"></a>
124 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>WriteStrEx
</b></font>( S:
<b>String
</b> ):
<b>DWord
</b>;
</font>
126 Writes string S to stream, also saving its size for future use by
127 ReadStrEx* functions. Returns number of actually written characters.
129 <a name=
"readstrexvar"></a>
131 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>ReadStrExVar
</b></font>(
<b>var
</b> S:
<b>String
</b> ):
<b>DWord
</b>;
</font>
133 Reads string from stream and assigns it to S.
134 Returns number of actually read characters.
136 String must be written by using
<a href=#writestrex
target=
"main">WriteStrEx
</a> function.
137 Return value is count of characters READ, not the length of string.
139 <a name=
"readstrex"></a>
141 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>ReadStrEx
</b></font>:
<b>String
</b>;
</font>
143 Reads string from stream and returns it.
145 <a name=
"writestrpas"></a>
147 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>WriteStrPas
</b></font>( S:
<b>String
</b> ):
<b>DWORD
</b>;
</font>
149 Writes a string in Pascal short string format -
1 byte length, then string
150 itself without trailing #
0 char. S parameter length should not exceed
255
151 chars, rest chars are truncated while writing. Total amount of bytes
154 <a name=
"readstrpas"></a>
156 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>ReadStrPas
</b></font>:
<b>String
</b>;
</font>
158 Reads
1 byte from a stream, then treat it as a length of following string
159 which is read and returned. A purpose of this function is reading strings
160 written using
<a href=#writestrpas
target=
"main">WriteStrPas
</a>.
162 <a name=
"seekasync"></a>
164 <font face=
"Courier" color=
"#800080"><b>procedure
</b> <font color=
"#808000"><b>SeekAsync
</b></font>( MoveTo:
<b>Integer
</b>; MoveMethod: TMoveMethod );
</font>
166 Changes current position asynchronously. To wait for finishing the
167 operation, use method
<a href=#wait
target=
"main">Wait
</a>.
169 <a name=
"readasync"></a>
171 <font face=
"Courier" color=
"#800080"><b>procedure
</b> <font color=
"#808000"><b>ReadAsync
</b></font>(
<b>var
</b> Buffer; Count:
<b>DWord
</b> );
</font>
173 Reads Count bytes from a stream asynchronously. To wait finishing the
174 operation, use method
<a href=#wait
target=
"main">Wait
</a>.
176 <a name=
"writeasync"></a>
178 <font face=
"Courier" color=
"#800080"><b>procedure
</b> <font color=
"#808000"><b>WriteAsync
</b></font>(
<b>var
</b> Buffer; Count:
<b>DWord
</b> );
</font>
180 Writes Count bytes from Buffer, starting from current position
181 in a stream - asynchronously. To wait finishing the operation,
182 use method
<a href=#wait
target=
"main">Wait
</a>.
186 <font face=
"Courier" color=
"#800080"><b>function
</b> <font color=
"#808000"><b>Busy
</b></font>:
<b>Boolean
</b>;
</font>
188 Returns TRUE until finishing the last asynchronous operation
189 started by calling
<a href=#seekasync
target=
"main">SeekAsync
</a>,
<a href=#readasync
target=
"main">ReadAsync
</a>,
<a href=#writeasync
target=
"main">WriteAsync
</a> methods.
193 <font face=
"Courier" color=
"#800080"><b>procedure
</b> <font color=
"#808000"><b>Wait
</b></font>;
</font>
195 Waits for finishing the last asynchronous operation.
197 <h4 align=
"center"><font color=
"black">Methods, inherited from
<a href=
"tobj.htm" target=
"_top">TObj
</a></font></h4>
198 <h3 align=
"center"><font color=
"#FF8080">TStream events
</font></h3>
199 <h4 align=
"center"><font color=
"black">Events, inherited from
<a href=
"tobj.htm" target=
"_top">TObj
</a></font></h4>
200 <h3 align=
"center"><font color=
"#FF8080">TStream fields
</font></h3>
201 <h4 align=
"center"><font color=
"black">Fields, inherited from
<a href=
"tobj.htm" target=
"_top">TObj
</a></font></h4>
203 <p align=
"center">[
<a href=index.htm
>Index
</a> ]
</p>
204 <p align=
"center"><font face=
"Comic Sans MS"><small>This help is generated
22-Sep-
2005 by KOL Help generator, (C)
2000-
2001 by Vladimir Kladov
<br>Modified (C)
2003 by Alexander Bartov
</small></font></p>