Function reads and returns all the characters from a file's record that was previously opened with the OpenRead function.  When ReadLine will read each line in the file and return its text contents until it reaches the End-of-Line marker sequence.


This call can be used in conjunction with the GetFieldCount to identify how many fields are in a comma delimited text file, and use the GetField functions to use that field count information to extract values the text record in the lineString variable supplied by the ReadLine function's file access.


ReadLine will only read the first 512 characters of the line.  If there are more characters then the fileManager.PartialLine flag will be set to true, and the next call to ReadLine will return the remaining characters.


When not using the optional lineIndex parameter, the file is read sequentially. When using the lineIndex parameter the file can be read random access. But note that this later method is much slower.



lineString = fileManager.ReadLine( fileNumber [,recordToRead] )





The open file identification number to read information.

[, recordToRead]

Optional:  The lineString returns the text record at the file's index location number in the recordToRead parameter.



'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VARIABLES: lineString Type: String
VARIABLES: fileNumber, recordToRead Type: Integer
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Open the file.
fileNumber = fileManager.OpenRead( "C:\FileToOpen.txt" )
If fileNumber > 0 THEN
  '  Loop reading lines until we reach the
  '  end of the file.
  Do UNTIL fileManager.EndOfFile( fileNumber )
    ' Read a line of text from the current file at the location value in recordToRead.
    lineString = fileManager.ReadLine( fileNumber, recordToRead )
    ' Print the text line
    PRINT lineString
  ' Close the file.
  fileManager.Close( fileNumber )
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


lineString = Text contents of the record read from the file.



DO, GetField, GetFieldCount, EndOfFile, PartialLine, OpenRead

See Also:

File Manager


Edit Time: 12/4/2018 3:33:04 PM

Topic ID#: 489


Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software