ReadFile()
Reads the contents of a binary file previously opened using OpenFile().
Syntax
ReadFile(<cFile>, <nBytes>) --> cData
Arguments
<cFile> --> is the name of the file to read from disk. A path and drive letter should be specified if applicable.
<nBytes> --> The number of bytes to read from the file. This should be in the range 0 to 65535.
Returns
Returns the data read from the disk file as a string. The length of cData indicates the number of bytes successfully read in. If the length of cData is zero or the length of the file is less than <nBytes> than either an error has occurred or you have read to the end of the file.
Description
This function is used to read the contents of a binary disk file. The file must already have been opened using OpenFile(). After you have completed reading the file, it must be closed using CloseFile().
Example
cFile := "C:\CAPITAL\Mydata.dat"
cData := ""
If OpenFile(cFile)
* Read all data from file and store
* in cData 2048 bytes at a time
* :LoopRead
cData := ReadFile(cFile, 2048)
If ( Len(cData) == 2048 ) Goto LoopRead
* If length of cData is less than 2048,
* there is no more data left to read from
* the file
CloseFile(cFile)
____________________________
Related Topics: