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","","All files (*.*)|*.*",0)
  If File$
    If ReadFile(0, File$)
      
      ; Read length of file
      Length = Lof(0)                       
      Debug "File length: "+FormatNumber(Length, 0)+" bytes"
          
      ; Set the file pointer 10 bytes from end of file
      FileSeek(0, Length - 10)                                
      Debug "Position after seek: "+FormatNumber(Loc(0), 0)
      
      CloseFile(0)
    Else
      Debug "Can't read the file: "+File$
    EndIf
  EndIf

See Also

Loc(), Lof()

Supported OS

All

<- FileID() - File Index - FlushFileBuffers() ->