Reads data from an opened OLE stream object.
To |
Use |
---|---|
Read data into a string |
|
Read data into a character array or blob |
Reads data from an OLE stream object into a string.
OLEStream objects
olestream.Read ( variable {, stopforline } )
Argument |
Description |
---|---|
olestream |
The name of an OLE stream variable that has been opened. |
variable |
The name of a string variable into which want to read data from olestream. |
stopforline (optional) |
A boolean value that specifies whether to read a line at a time. In other words, Read will stop reading at the next carriage return/linefeed. Values are:
|
Integer. Returns the number of characters or bytes read. If an end-of-file mark (EOF) is encountered before any characters are read, Read returns -100. Read returns one of the following negative values if an error occurs:
-1 Stream is not open
-2 Read error
-9 Other error
If any argument’s value is null, Read returns null.
This example opens an OLE object in the file MYSTUFF.OLE and assigns it to the OLEStorage object stg_stuff. Then it opens the stream called info in stg_stuff and assigns it to the stream object olestr_info. Finally, it reads the contents of olestr_info into the string ls_info.
The example does not check the functions’ return values for success, but you should be sure to check the return values in your code:
boolean lb_memexists
OLEStorage stg_stuff
OLEStream olestr_info
blob ls_info
stg_stuff = CREATE OLEStorage
stg_stuff.Open("c:\ole2\mystuff.ole")
olestr_info.Open(stg_stuff, "info", &
stgRead!, stgExclusive!)
olestr_info.Read(ls_info)
Reads data from an OLE stream object into a character array or blob.
OLEStream objects
olestream.Read ( variable {, maximumread } )
Argument |
Description |
---|---|
olestream |
The name of an OLE stream variable that has been opened. |
variable |
The name of a blob variable or character array into which want to read data from olestream. |
maximumread (optional) |
A long value specifying the maximum number of bytes to be read. The default is 32,765 or the length of olestream. |
Integer. Returns 0 if it succeeds and one of the following negative values if an error occurs:
-1 Stream is not open
-2 Read error
-9 Other error
If any argument’s value is null, Read returns null.
This example opens an OLE object in the file MYSTUFF.OLE and assigns it to the OLEStorage object stg_stuff. Then it opens the stream called info in stg_stuff and assigns it to the stream object olestr_info. Finally, it reads the contents of olestr_info into the blob lb_info.
The example does not check the functions’ return values for success, but you should be sure to check the return values in your code:
boolean lb_memexists
OLEStorage stg_stuff
OLEStream olestr_info
blob lb_info
stg_stuff = CREATE OLEStorage
stg_stuff.Open("c:\ole2\mystuff.ole")
olestr_info.Open(stg_stuff, "info", &
stgRead!, stgExclusive!)
olestr_info.Read(lb_info)