Repositions the file pointer associated with hFile to a new location that is lOffset from enOrigin.
[ lNewPos = ] FileSeek ( hFile, lOffset [, enOrigin ] )
The FileSeek procedure syntax has the following parts:
Name |
Type |
Description |
lNewPos |
Long |
The file pointer new position |
hFile |
Val AFile |
Handle to an open file |
lOffset |
Val Long |
Offset in bytes |
enOrigin |
enumAFileOrigin |
Starting position in the file |
enumAFileOrigin can be one of the following values, with the allowable default values marked with an asterisk(*):
Name |
Value |
Description |
aFileOriginBegin |
0 * |
Beginning of the file. Move the file pointer lOffset bytes from the beginning of the file. |
aFileOriginCurrent |
1 |
Current position of the file pointer. Move the file pointer lOffset bytes from its current position in the file (may be obtained by the FileTell procedure). |
aFileOriginEnd |
2 |
End of file. Move the file pointer lOffset bytes from the end of the file. |
The function returns the value in bytes of the new file pointer's position from the beginning of the file. If the function fails, it returns -1.
When a file is initially opened (using the FileCreate or FileOpen function), the file pointer is positioned at the beginning of the file. The FileRead and FileWrite may also change the file pointer position.
The FileSeek function permits random access to a file's contents by moving the file pointer randomly without reading or writing data.
The following example moves the file pointer to the end of the file and prints the file size in bytes:
lNewPos=FileSeek(hFile, 0, aFileOriginEnd)
If lNewPos >= 0 Then
Print "New Position is:"; lNewPos
Else
Print "Error During FileSeek..."
Endif
FileCreate, FileEOF, FileOpen, FileRead, FileTell, FileWrite