FileRead (Read File)

The FileRead function reads a file referenced by a FileHandle and stores the results in a variable or variable array.

Syntax

FileRead (FileHandle, Destination, Length )

Remarks

The FileRead function returns the number of bytes successfully read. This function reads to the end of the file or to the maximum number of bytes (Length parameter). To read only one line of a file, use the FileReadLine function.

With files opened for writing in ASCII text, every line feed character is replaced with a carriage return. When reading ASCII text files, all carriage return characters (CHR(13)) are discarded and line feed characters (CHR(10)) are converted to end of line.

Parameters

FileHandle (File Handle)

The program reference to the file being read from, written to, or otherwise affected by the function. A FileHandle is created by a FileOpen function and deleted by FileClose. Recommended variable type is Long.

Type: Variable

Destination

The variable in which the results of the read should be stored.

Type: Variable declared as a string

Length

Specifies the maximum number of characters to be read in to the Destination variable. If Destination is an array, Length must equal to at least the total of the number of bytes for all elements in the array. For example, if you are reading 3 elements of an array and each element is 4 bytes, Length must be at least 12.

Type: Variable

To read each file using a unique name, refer to FilesManager.