Reads data from a file.


FileRead (filehandle)


(i) filehandle same integer that was returned by FileOpen.


(s) line of data read from file.


When the end of the file is reached, the string *EOF* will be returned.

Note: This function expects standard DOS CR-LF terminated lines in the file. It will read the next unread line from the file and return that line without the CR-LF on the end. FileRead strips out any NULL's from the file being read.

Also, the default maximum length of a line, which can be read using the FileRead function is 4096 bytes. If you need to increase the length of line that FileRead can read see IntControl 65.

FileRead can be used to read files containing Unicode data, and will automatically determine the correct file type (ANSI or Unicode), regardless of the "Unicode" parameter in FileOpen, and will convert the return string if necessary.



;Read through file line by line
testfile = FileLocate("win.ini")
handle = FileOpen(testfile, "READ")
count = 0
While @TRUE ; Loop till break do us end
   line = FileRead(handle)
   If line == "*EOF*" Then Break
   count = count + 1
   Message(StrCat("Line # ",count), line)
See Also:

FileClose, FileGet, FileOpen, FileWrite, IntControl 65