FileSeek()
Syntax
FileSeek(#File, NewPosition.q [, Mode])Description
Change the read/write pointer position in the file.
Parameters
#File The file to use. NewPosition.q The new position relative to the beginning of the file in bytes. Mode (optional) The seek mode. It can be one of the following values: #PB_Absolute: the 'NewPosition' parameter will be an absolute position with the file (default). #PB_Relative: the 'NewPosition' parameter will be an offset (positive or negative) relative to the current file pointer position.
Return value
None.
Example
file$ = OpenFileRequester("Select a file","","Text (.txt)|*.txt|All files (*.*)|*.*",0)
If file$
If ReadFile(0, file$)
length = Lof(0) ; read length of file
FileSeek(0, length - 10) ; set the file pointer 10 chars from end of file
Debug "Position: " + Str(Loc(0)) ; show actual file pointer position
*MemoryID = AllocateMemory(10) ; allocate the needed memory for 10 bytes
If *MemoryID
bytes = ReadData(0, *MemoryID, 10) ; read this last 10 chars in the file
Debug PeekS(*MemoryID)
EndIf
CloseFile(0)
EndIf
EndIf
See Also
Loc(), Lof()
Supported OS
All