Xbasic

FILE.READ Function

Syntax

Text as C = file_pointer.Read(N Length)

Arguments

LengthNumeric

The number of characters to read.

Returns

TextCharacter

Returns a string containing the data read from the file.

Description

Read bytes from file into string.

Discussion

The .READ() method retrieves a specified Number_of_Characters from a file starting at the current file offset. The .READ() method returns a string of the input characters that includes any CR and LF codes.

Example

This script reads 4 groups of 4 characters each from the defaults file.

dim data(4) as C
file_pointer = file.open("c:\a5\defaults.txt", FILE_RW_SHARED)
for i = 1 TO 4
    Data[i] = file_pointer.read(4)
    trace.writeln(data[i])
next i
file_pointer.close()

See Also