Xbasic

FILE.WRITE_LINE Function

Syntax

Bytes_Written as N = file_pointer.Write_line(C Data)

Arguments

DataCharacter

A variable or expression containing character data.

Returns

Bytes_WrittenNumeric

Returns the number of bytes written to the file.

Description

Writes a string to file with a trailing CR-LF.

Discussion

The .WRITE_LINE() method writes a line of text data ( Text_Line ) to the location of the current file pointer in an open file referenced by the file object pointer. The CR (Carriage Return) and LF (Line Feed) codes are appended to the end of the output.

Example 

This script retrieves the names of customers from the customer table and writes them to an output file.

dim tbl as P
tbl = table.open("c:\a5\a_sports\customer.dbf")
file_pointer = file.create("c:\a5\output.txt", FILE_RW_EXCLUSIVE)
tbl.fetch_first()
while .NOT. tbl.fetch_eof()
    file_pointer.write_line(tbl.first_name - " " + tbl.last_name)
    tbl.fetch_next()
end while
file_pointer.flush()
file_pointer.close()

See Also