readLine

readLine(): String;

The readLine method of the File class returns a string containing the next line in the file. A line is delimited by the endOfLine character sequence. An empty string is returned when the end of file has been reached. The readLine method automatically opens the file if it is not already open.

If the line (or record) exceeds the value of the maxRecordSize property, it is truncated to that value and an exception is raised.

This method is valid only for files that are opened as text file. An exception is raised if the readLine method is attempted on a file opened as binary.

If an ANSI version of JADE reads from a Unicode file, the string is automatically converted from Unicode to ANSI before it is returned. If a Unicode version of JADE reads from an ANSI file, the string is automatically converted from ANSI to Unicode before it is returned.

The following example shows the use of the readLine method.

modifyFile();
constants
    FileNameIn          : String = 'c:\jade\bin\x2.run';
    FileNameOut         : String = 'c:\jade\xx2.run';
vars
    fOut, fIn    : File;
    recordCount  : Integer;
    outputString : String;
    inputString  : String;
    temp2        : String;
begin
    create fIn;
    create fOut;
    fIn.kind      := File.Kind_Unknown_Text;
    fOut.mode     := File.Mode_Output;
    fIn.mode      := File.Mode_Input;
    fOut.fileName := FileNameOut;
    fIn.fileName  := FileNameIn;
    fOut.open;
    fIn.open;
    recordCount  := 1;
    while not fIn.endOfFile do
        inputString := fIn.readLine;
        inputString[60 : 4 ] := '0000';
        temp2 := recordCount.String;
        inputString [64 - temp2.length : temp2.length ] := temp2;
        fOut.writeLine(inputString);
        recordCount := recordCount + 1;
    endwhile;
    fOut.close;
    fIn.close;
epilog
    delete fOut;
    delete fIn;
end;

The maximum size of data that can be read by the readLine method when the value of the FileNode class usePresentationFileSystem property is set to true is 2G bytes. If this limit is exceeded, exception 5047 (Invalid record size) is raised.