Reading from a low level file with FoxPro

The FREAD (<filehandle>,<numbytes>) function reads <numbytes> characters from the file. It starts reading from the current position in the file and moves its pointer <numbytes> characters along the file time each time that you call this function. If you ask it to read more bytes than there are in the file then it will return all the bytes available and move the pointer beyond the end of the file. No error will be raised when this happens but you can call the FEOF() function to test whether you have passed the end of the file.

This example reads groups of 10 bytes from a text file and prints them out.

lnFileHandle= FOPEN("file.txt")
  ?FREAD(lnFileHandle, 10)

The FREAD() function treats all characters in the same way. It ignores the special meaning of ASCII characters 10 and 13 (LineFeed and CarriageReturn) and counts them as individual characters. Another low level function, FGETS() will read complete lines of characters and is much more suitable for processing text files.