Read

For OLE stream objects Reads data from an opened OLE stream object.

To

Use

Read data into a string

Syntax 1 For reading into a string

Read data into a character array or blob

Syntax 2 For character arrays or blobs

For FileDirect objects Reads a file that you open using the FileDirect object.

To

Use

Read data into an array

Syntax 3 For reading data into an array

Read data into a blob

Syntax 4 For reading data into a blob


Syntax 1 For reading into a string

Description

Reads data from an OLE stream object into a string.

Applies to

OLEStream objects

Syntax

olestream.Read ( variable {, stopforline } )

Returns

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 a negative integer if an error occurs.


Syntax 2 For character arrays or blobs

Description

Reads data from an OLE stream object into a character array or blob.

Applies to

OLEStream objects

Syntax

olestream.Read ( variable {, maximumread } )

Returns

Integer. Returns 0 if it succeeds and a negative integer if an error occurs.


Syntax 3 For reading data into an array

Description

Reads data from an open file into an array.

Applies to

FileDirect objects

Syntax

Integer instancename.Read ( data[ ], bytesrequested, bytesread)

Argument

Description

instancename

Name of the instance of the FileDirect object

data[ ]

An array of unsignedlong datatypes to contain the data that you read from a file

bytesrequested

Integer for the number of bytes that you want to read in the open file

bytesread

Integer for storing the number of bytes read in the file

Returns

Integer. Returns 1 for success and a negative number for any error.

Usage

Use this function to read a file that you open with the FileDirect object in read mode. The FileDirect object supports only the synchronous style of file output; further file-related commands cannot be called until after the Read function is fully processed or an error in reading the file is caught.

Examples

Example 1

The following example calls the FileDirect user object nvo_fileDirect to open a file, read some data, store the data in an array, and close the file:

Integer li_ret, li_AmountRead

Unsignedlong li_data [ ]
li_ret = nvo_fileDirect.Open ("COM8:", stgReadWrite!)
li_ret = nvo_fileDirect.Read (li_data[], 100,     li_amountRead)
li_ret = nvo_fileDirect.Close ( )

See also


Syntax 4 For reading data into a blob

Description

Reads data from an open file into a blob.

Applies to

FileDirect objects

Syntax

Integer instancename.Read ( bdata, bytesrequested, bytesread)

Argument

Description

instancename

Name of the instance of the FileDirect object

bdata

A blob variable to hold the data that you read from a file

bytesrequested

Integer for the number of bytes that you want to read in the open file

bytesread

Integer for for storing the number of bytes read in the file

Returns

Integer. Returns 1 for success and a negative number for any error.

Usage

Use this function to read a file that you open with the FileDirect object in read mode. The FileDirect object supports only the synchronous style of file output; further file-related commands cannot be called until after the Read function is successfully processed or until an error in reading the file is caught.

Examples

Example 2

The following example calls the FileDirect user object nvo_fileDirect to open a file, read some data, store the data in a blob variable, and close the file:

Integer li_ret, li_AmountRead
Blob lb_data
li_ret = nvo_fileDirect.Open ("MyDoc.txt", stgRead!)
li_ret = nvo_fileDirect.Read (lb_data, 100,     li_amountRead)
li_ret = nvo_fileDirect.Close ( )

See also