Click or drag to resize

FTell Function

Return the current position of the file pointer.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.2a
Syntax
 FUNCTION FTell(
	ptrHandle AS IntPtr
) AS DWORD
View Source

Parameters

ptrHandle
Type: IntPtr
The handle of the file to examine.

Return Value

Type: UInt32
The current position of the file pointer, relative to the beginning of the file.
Remarks
FTell() gets the current file position.  This corresponds to the current physical byte offset for files opened in binary mode.
Remarks
Tip Tip
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()
Examples
This example uses FTell() to reflect the file pointer position before and after an FWrite() and an FSeek():
X#
hF := FOpen2("myfile.txt", FO_READWRITE)
IF hF != F_ERROR
        ? FTell(hF)                                //  0
        FWrite3(hF, "Hello", 5)
        ? FTell(hF)                                //  5
        FSeek3(hF, 10, FS_SET)
        ? FTell(hF)                                //  10
ELSE
        ? "Open failed"
ENDIF
See Also