Read in a line of text from a previously opened text file.
FileReadLine ( filehandle or "filename" [, line] )
Parameters
filehandle | The handle of a file, as returned by a previous call to FileOpen. Alternatively you may use a string filename as the first parameter. |
line | [optional] The line number to read. The first line of a text file is line 1 (not zero). |
Return Value
Success: | Returns a line of text. |
Special: | Sets @error to -1 if end-of-file is reached. |
Failure: | Sets @error to 1 if file not opened in read mode or other error. |
Remarks
Returns the text of the line read, any newline characters ( CHR(10) or @LF ) at the end of a line read in are automatically stripped.
Related
IniRead, FileClose, FileOpen, FileRead, FileWrite, FileWriteLine
Example
$file = FileOpen("test.txt", 0)
; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
; Read in lines of text until the EOF is reached
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
MsgBox(0, "Line read:", $line)
Wend
FileClose($file)