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.

 

Syntax:

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

 

Parameter:

Description:

fileNumber

The open file identification number to read information.

[, lineIndex]

Optional:  The line index to return, or when used to access a record, it will read the record at the index value assigned.

 

Example:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VARIABLES: lineString Type: String
VARIABLES: fileNumber 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 from the current file.
     lineString = fileManager.ReadLine( fileNumber )
     
    ' Print the line
    PRINT lineString
  LOOP
 
  ' Close the file.
  fileManager.Close( fileNumber )
ENDIF
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Returns:

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

 

Links:

DO, GetField, GetFieldCount, EndOfFile, PartialLine, OpenRead

See Also:

File Manager

 


Edit Time: 9/25/2017 09:09:58 AM


Topic ID#: 489

 

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