Moves the file pointer to the specified position in a file whose size does not exceed 2GB. The file pointer is the position in the file at which the next read or write begins.
Effects of file format on character recognition FileSeek can only be used in stream mode. It moves the pointer a specified number of bytes and does not take the size of Unicode characters into account. If you use FileSeek in a Unicode file and move the pointer to a position in the middle of a Unicode character, the character is not recognized and a FileRead from that position results in unexpected behavior.
FileSeek ( file#, position, origin )
Argument |
Description |
---|---|
file# |
The integer assigned to the file when it was opened. |
position |
A long whose value is the new position of the file pointer relative to the position specified in origin, in bytes. |
origin |
The value of the SeekType enumerated datatype specifying where you want to start the seek. Values are:
|
Long. Returns the file position after the seek operation has been performed. If any argument’s value is null, FileSeek returns null.
Use FileSeek to move within a binary file that you have opened in stream mode. FileSeek positions the file pointer so that the next FileRead or FileWrite occurs at that position within the file.
The FileSeek function cannot handle files whose size exceeds 2GB.
This example positions the file pointer 14 bytes from the end of the file:
integer li_FileNum
li_FileNum = FileOpen("emp_data")
FileSeek(li_FileNum, -14, FromEnd!)
This example moves the file pointer from its current position 14 bytes toward the end of the file. In this case, if no processing has occurred after FileOpen to affect the file pointer, specifying FromCurrent! is the same as specifying FromBeginning!:
integer li_FileNum
li_FileNum = FileOpen("emp_data")
FileSeek(li_FileNum, 14, FromCurrent!)