FUNCTION FReadText3( ptrHandle AS IntPtr, ptrBufferVar AS BYTE, dwBytes AS DWORD ) AS DWORD
public static uint FReadText3( IntPtr ptrHandle, byte ptrBufferVar, uint dwBytes )
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 function FGetStream()
1DEFINE F_BLOCK := 128 2Function Start() 3 LOCAL cBuffer AS PTR 4 cBuffer := MemAlloc(F_BLOCK) 5 IF cBuffer = NULL PTR 6 RETURN FALSE 7 ENDIF 8 ptrHandle := FOpen("temp.txt") 9 IF ptrHandle = F_ERROR 10 ? DOSErrString(FError()) 11 RETURN FALSE 12 ELSE 13 IF FReadText3(ptrHandle, cBuffer, F_BLOCK) <> F_BLOCK 14 ? DOSErrString(FError()) 15 RETURN FALSE 16 ENDIF 17 FClose(ptrHandle) 18 ENDIF 19 MemFree(cBuffer) 20 RETURN TRUE