@FILESEEK[n,offset,start] Moves the file pointer of the file whose handle is n by offset bytes from the reference location specified via start (see  the table below). The return value of @FILESEEK is the offset of the file pointer from the beginning of the file after the specified move. If offset is negative, the file pointer is moved from the reference location toward the beginning of the file. If offset is positive, the file pointer is moved from the reference location toward the end of the file. If offset is 0, the pointer is moved to the reference location.

 

If the function fails, the return value is -1.

 

start

reference location

0

beginning of file

1

current file pointer

2

end of file

 

Numeric input may be entered in either decimal format (a sequence of 0-9 digits) or in hexadecimal format ("0x" followed by a sequence of 0-F hex digits).

 

This function should only be used with file handles returned by @FILEOPEN. If you use it with any other number you may damage other files opened by TCC (or by the program which started TCC).

 

Useful special cases

 

If you set offset to 0 :

 

@FILESEEK[n,0,0] moves the file pointer to the beginning of file

@FILESEEK[n,0,1] returns the current location of the file pointer without moving it.

@FILESEEK[n,0,2] moves the file pointer to the end of file, and returns the current file size.

 

Example:

 

set h=%@fileopen["d:\path\myfile.txt",rw]

echo file size = %@fileseek[%h,0,2]

echo closing handle #%h: %@fileclose[%h]

 

See also the related handle-based functions:

 

@FILECLOSEClose a file handle
@FILEOPENOpen a file handle
@FILEREADRead next line from a file handle
@FILESEEKLMove a file handle pointer to a specified line
@FILEWRITEWrite next line to a file handle
@FILEWRITEBWrite data to a file handle
@TRUNCATETruncate the file at the current position of the file handle pointer.