FSeek Function | |
Set the file pointer to a new position.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION FSeek(
ptrHandle,
nOffset,
kOrigin
) AS LONG CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static int FSeek(
Usual ptrHandle = default,
Usual nOffset = default,
Usual kOrigin = default
)
Request Example
View SourceParameters
- ptrHandle (Optional)
- Type: Usual
The handle of the open file. - nOffset (Optional)
- Type: Usual
The number of bytes to move the file pointer, from the position defined by nOrigin.
It can be a positive or negative number.
A positive number moves the pointer forward in the file, and a negative number moves the pointer backward.
If nOrigin is the end-of-file, nOffset must be 0 or negative.
- kOrigin (Optional)
- Type: Usual
One of the following constants indicating the starting location of the file pointer, telling where to start searching the file:
Constant | Seeks from |
---|
FS_END | End-of-file |
FS_RELATIVE | Current pointer position |
FS_SET | Beginning-of-file |
Return Value
Type:
Long
The new position of the file pointer, relative to the beginning of the file (position 0). (The original position of the file pointer does not matter.)
Remarks
FSeek() is a low-level file function that moves the file pointer forward or backward in an open file without actually reading the contents of the specified file.
The file pointer cannot be moved beyond the beginning or end-of-file boundaries.
Remarks Tip |
---|
This function is included for compatibility. We do not recomment using static memory for file i/o operations.
We recommend that you use the function overload that takes a byte array parameter in stead.
|
Examples
This example uses FSeek() to determine the length of a file by seeking from the end-of-file.
Then, the file pointer is reset to the beginning-of-file:
1
2IF (ptrHandle := FOpen2("temp.txt", FO_READ)) != F_ERROR
3
4 nLength := FSeek(ptrHandle, 0, FS_END)
5
6 FSeek(ptrHandle, 0)
7 FClose(ptrHandle)
8ELSE
9 ? DOSErrString(FError())
10ENDIF
This example positions the file pointer at the last byte in a file:
1FUNCTION FileBottom(ptrHandle) AS LONGINT
2 RETURN (FSeek(ptrHandle, 0, FS_END))
This example positions the file pointer at the first byte in a file (same as the Rewind() function):
1FUNCTION FileTop(ptrHandle) AS LONGINT
2 RETURN (FSeek(ptrHandle, 0))
See Also