Read characters from a file into a buffer variable that is passed by reference.
XSharp.Core (in XSharp.Core.dll) Version: 2.4a
Syntax View Source
ptrHandle AS IntPtr,
cBufferVar REF STRING,
dwBytes AS DWORD
) AS DWORD
public static uint FReadText(
ref string cBufferVar,
- Type: IntPtr
The handle of the file to read from.
- Type: String
A variable used to store data read from the specified file.
If the length of <cBufferVar> is less than <dwBytes>, a new string whose length is the minimum of <dwBytes> and the remaining bytes in the file is allocated. <cBufferVar> must be passed by reference and, therefore, must be prefaced by the pass-by-reference operator (@).
- 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.
FReadText() is the same as FRead() except that an OEM to ANSI conversion is made if SetAnsi() is FALSE.
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 FRead() after successfully opening a file to read 128 bytes into a buffer area:
1DEFINE F_BLOCK := 128
3cBuffer := Space(F_BLOCK)
4ptrHandle := FOpen("temp.txt")
5IF FError() != 0
6 ? DOSErrString(FError())
8 IF FReadText(ptrHandle, @cBuffer, F_BLOCK) <> F_BLOCK
9 ? DOSErrString(FError())