Write

Writes data to an OLE stream object or a file that you open with the FileDirect object.

To

Use

Write data to an OLE stream object

Syntax 1 For an OLE stream object

Write data into an array

Syntax 2 For writing data from an array of bytes

Write data into a blob

Syntax 3 For writing data from a blob


Syntax 1 For an OLE stream object

Description

Writes data to an opened OLE stream object.

Applies to

OLEStream objects

Syntax

olestream.Write ( dataforstream )

Returns

Integer. Returns the number of characters or bytes written if it succeeds and A negative integer if an error occurs.


Syntax 2 For writing data from an array of bytes

Description

Writes data from an array into an open file.

Applies to

FileDirect objects

Syntax

Integer instancename.Write ( data[ ], bytecount)

Argument

Description

instancename

Name of the instance of the FileDirect object

data[ ]

An array of integers representing bytes of data

bytecount

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

Returns

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

Usage

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

Examples

Example 1

The following example calls the FileDirect user object nvo_fileDirect to open a file, write some data, and close the file:

Integer li_ret, li_AmountRead, li_data [ ]
li_ret = nvo_fileDirect.Open ("COM8:", stgReadWrite!)
li_ret = nvo_fileDirect.Write (li_data[], 100)
li_ret = nvo_fileDirect.Close ( )

See also


Syntax 3 For writing data from a blob

Description

Writes data from a blob to an open file.

Applies to

FileDirect objects

Syntax

Integer instancename.Write ( bdata, bytecount)

Argument

Description

instancename

Name of the instance of the FileDirect object

bdata

A blob variable holding the data that you write to a file

bytescount

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

Returns

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

Usage

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

Examples

Example 2

The following example calls the FileDirect user object nvo_fileDirect to open a file, write some data, and close the file:

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

See also