Read characters from a file into an allocated buffer.
XSharp.Core (in XSharp.Core.dll) Version: 2.5
ptrHandle AS IntPtr,
ptrBufferVar AS BYTE,
dwBytes AS DWORD
) AS DWORD
public static uint FRead3(
- Type: IntPtr
The handle of the file to read from.
- Type: Byte
Pointer to an allocated buffer used to store data read from the specified file.
The length of this variable must be greater than or equal to <dwBytes>.
An array of bytes to store the data read from the specified file. The length of this variable must be greater than or equal to the number of bytes in the next parameter.
- Type: UInt32
The number of bytes to read into the buffer.
The number of bytes successfully read.
A return value less than <dwBytes> or 0 indicates end-of-file or some other read error. FError() can be used to determine the specific error.
FRead3() is the same as FRead(), except that the name of the buffer variable is a pointer and is not passed by reference.
See FRead() for details.
This function is assumed to handle raw binary data and is not dependent upon the status of SetAnsi(). FReadText() and FRead4(), on the other hand, are dependent upon SetAnsi().
The low level File IO functions in the X# runtime are using .Net filestreams in the background. |
That means that the file handles returned by FOpen() and FCreate() are not 'normal' file handles,
but unique identifiers that are used to find the underlying stream object in a collection of
streams in the runtime.
That also means that you can't use file handles for functions such as FRead() and FWrite() that were not
created in the X# runtime.
If you want to access the underlying FileStream, then you should call the
This example uses FRead3() after successfully opening a file to read 128 bytes into a buffer area:
1DEFINE F_BLOCK := 128
3 LOCAL cBuffer AS PTR
4 cBuffer := MemAlloc(F_BLOCK)
5 IF cBuffer = NULL PTR
6 RETURN FALSE
8 ptrHandle := FOpen2("temp.txt", FO_READ)
9 IF ptrHandle = F_ERROR
10 ? DOSErrString(FError())
11 RETURN FALSE
13 IF FRead3(ptrHandle, cBuffer, F_BLOCK) <> F_BLOCK
14 ? DOSErrString(FError())
15 RETURN FALSE
20 RETURN TRUE