Xbasic

FILE.WRITE Function

Syntax

Bytes_Written as N = file_pointer.Write(C data [,N Length])

Arguments

dataCharacter

A variable or expression containing character data.

LengthNumeric

Default = all. The number of bytes to write.

Returns

Bytes_WrittenNumeric

Returns the number of bytes written to the file.

Description

Writes data to a file.

Discussion

The .WRITE() method transfers the contents of a Text string to the location of the current file pointer in the open file referenced by the file object pointer. The optional Number_of_Bytes parameter specifies the number of bytes (or characters) from Text that will be written to the file.

Example

This script creates a defaults file with 4 groups of 4 characters, VAR1 .. VAR4.

file_pointer = FILE.create("C:\a5\defaults.txt", FILE_RW_EXCLUSIVE)
for i = 1 TO 4
    file_pointer.write("VAR" + ltrim( str(i) ) )
next i
file_pointer.flush()
file_pointer.close()

See Also