Click or drag to resize

FTell Function

X#
Return the current position of the file pointer.

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

Parameters

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

Return Value

Type: DWord
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(IntPtr)
Examples
This example uses FTell() to reflect the file pointer position before and after an FWrite() and an FSeek():
X#
 1hF := FOpen2("myfile.txt", FO_READWRITE)
 2IF hF != F_ERROR
 3    ? FTell(hF)                //  0
 4    FWrite3(hF, "Hello", 5)
 5    ? FTell(hF)                //  5
 6    FSeek3(hF, 10, FS_SET)
 7    ? FTell(hF)                //  10
 8ELSE
 9    ? "Open failed"
10ENDIF
See Also