FileWrite Procedure

Writes bytes to the specified file.

Syntax

[ lBytesWritten = ] FileWrite ( hFile, pSrc [, lBytes ] [, sEOS ] [, enMode ] )

The FileWrite procedure syntax has the following parts:

 

Name

Type

Description

lBytesWritten

Long

Number of bytes written

hFile

Val AFile

Handle to an open file

pSrc

Val Any

Source data buffer

lBytes

Val Long

Maximum number of data bytes to write. When the default value (-1) is used the size of the write buffer pSrc is used.

sEOS

Val BString

Terminator string

enMode

Val enumAIoMode

Output send mode. Only the default value is 0 (aioDefault) which can be combined with aioDisableBstrConvert.

Where

enumAIoMode can have one of the following values:

 

Name

Value

Description

aioImmediate

0 *

Receive on data available

aioWaitGpibSrqVxiDor

1

Receive on Srq (gpib) or on Dor (vxi)

aioGpibImmediateOrSrq

2

Receive on Immediate or Srq (gpib)

aioDisableBstrConvert

4

Disable conversion of BString to String, can be combined with one of the previous values.

Comments

Writes bytes (optional) from the given location to a file associated with hFile.

The function writes the data starting with the current position of the file pointer. The file pointer is increased by the number of bytes actually written. The function returns the number of bytes actually written. It returns -1 if the function fails.

If the optional parameter lBytes is not supplied, lBytes is calculated internally by the procedure using the the size of the pSrc parameter. The default value is -1.

If the terminator string (sEos) is given, it will be appended to the Source data before it is sent.

Example

The following example will write the first four letters of the alphabet, followed by a carriage return and line feed, to the file specified by hFile:

i=FileWrite(hFile, "abcd", , "\r\n")

if i<>6

TestStatus=FAIL

endif

See Also

FileRead, FileSeek