Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The fSeek( hFile, nPosition ) function has a limitation???

Status
Not open for further replies.

JOHNNYDEAUVILLE

Programmer
Nov 4, 2003
2
ES
The fSeek( hFile, nPosition ) function has a limitation that affects to the nPosition parameter???

In affirmative case, ¿what is the maximum value of nPosition?

Thank's a lot for the posible answers.
 
nFileSize

What version of clipper are you using?

Rob.
 
FSEEK()
Set a binary file pointer to a new position
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Syntax

FSEEK(<nHandle>, <nOffset>, [<nOrigin>]) --> nPosition

Arguments

<nHandle> is the file handle obtained from FOPEN(), FCREATE(), or
predefined by DOS.

<nOffset> is 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, and a negative number moves
the pointer backward in the file.

<nOrigin> defines the starting location of the file pointer before
FSEEK() is executed. The default value is zero, representing the
beginning of file. If <nOrigin> is the end of file, <nOffset> must be
zero or negative.

Methods of Moving the File Pointer
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
Origin Fileio.ch Description
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
0 FS_SET Seek from beginning of file
1 FS_RELATIVE Seek from the current pointer position
2 FS_END Seek from end of file
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

Returns

FSEEK() returns the new position of the file pointer relative to the
beginning of file (position 0) as an integer numeric value. This value
is without regard to the original position of the file pointer.

Description

FSEEK() is a low-level file function that moves the file pointer forward
or backward in an open binary file without actually reading the contents
of the specified file. The beginning position and offset are specified
as function arguments, and the new file position is returned.
Regardless of the function arguments specified, the file pointer cannot
be moved beyond the beginning or end of file boundaries.

Warning! This function allows low-level access to DOS files and
devices. It should be used with extreme care and requires a thorough
knowledge of the operating system.

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:

#include &quot;Fileio.ch&quot;
//
// Open the file read-only
IF (nHandle := FOPEN(&quot;Temp.txt&quot;)) >= 0
//
// Get length of the file
nLength := FSEEK(nHandle, 0, FS_END)
//
// Reset file position to beginning of file
FSEEK(nHandle, 0)
FCLOSE(nHandle)
ELSE
? &quot;File open error:&quot;, FERROR()
ENDIF

þ This pseudofunction positions the file pointer at the last
byte in a binary file:

#define FileBottom(nHandle);
(FSEEK(nHandle, 0, FS_END))

þ This pseudofunction positions the file pointer at the first
byte in a binary file:

#define FileTop(nHandle);
(FSEEK(nHandle, 0))

þ This pseudofunction reports the current position of the file
pointer in a specified binary file:

#define FilePos(nHandle);
(FSEEK(nHandle, 0, FS_RELATIVE))

Files: Library is CLIPPER.LIB, header file is Fileio.ch.


Rob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top