Previous Topic: ReadFile - Read Data from a FileNext Topic: WriteFile - Write Data to a File


SeekFile - Reposition the Current Position in an Open File

Valid on NetWare, Symbian OS, UNIX, Windows and Windows CE

The SeekFile function repositions the current position in an open file.

This file content function has the format:

Seekfile(handle as integer, position as integer) as Boolean
handle

Identifies a handle returned by a previous call.

position

Indicates the new position in the file. A position of 0 sets the position to the beginning of the file. The next read or write will be at the new position in the file.

On successful completion, the function returns TRUE; otherwise, it returns FALSE.

Example: SeekFile function

'	Update a file at the 4th double word. set it to 0.
Dim fHandle as integer

fHandle = OpenFile("out5.a", O_UPDATE)
if (fHandle = -1) then
	Print("OpenFile(""out5.a"", O_UPDATE) failed.")
	exit
endif
if Not(SeekFile(fHandle, 16)) then
	Print("SeekFile(fHandle, 16) failed.")
	exit
endif
if Not(WriteFile(fHandle, 0)) then
	Print("WriteFile(fHandle, 0) failed.")
	exit
endif
CloseFile(fHandle)