ReadLine method: File class

Syntax

ReadLine(string)

Description

The ReadLine method reads one line of text from the external file. The line includes the newline character, but ReadLine strips out the newline character and inserts the result into the string variable string.

When ReadLine is executed, it moves the starting point for the next read operation to the end of the text just retrieved, so each line in the file can be read in turn by subsequent ReadLine operations. When no more data remains to be read from the file, ReadLine returns False, and clears the string variable of any content.

When the file object has been instantiated using a Unicode character set (UTF8, UTF8BOM, or UCS2) and the file has a Unicode byte order mark (BOM), the BOM is recognized as file metadata and is not treated as text. However, when the file has been instantiated using a non-Unicode character set and the file has a Unicode BOM, this is likely a user error; the BOM is treated as text and is not recognized as file metadata.

Parameters

Parameter Description

string

A string variable that receives the input text.

Returns

A Boolean value: True if the method succeeds, False otherwise. The return value is not optional, it is required.

Example

The following example reads a file called &MYFILE and puts each line as a separate element in an array.

Local File &MYFILE;
Local array of string &MYARRAY;
Local string &TEXT;

&MYFILE = GetFile("names.txt", "R", "UTF8BOM");
&MYARRAY = CreateArrayRept("", 0);
While &MYFILE.ReadLine(&TEXT);
   &MYARRAY.Push(&TEXT);
End-While;
&MYFILE.Close();