You can use the \(\text{FileSeek}\) function to position a file pointer in a file.

You can use the \fileseek backslash command to insert this function.

The following variants of this function are available:

  • \(\text{boolean } \text{FileSeek} \left ( \text{<file number>}, \text{<offset>} \right )\)

The \(\text{<file number>}\) parameter is an integer value returned by one of the \(\text{FileOpen}\ldots\) functions. The \(\text{<offset>}\) parameter indicates the byte offset into the file where you want the file pointer to be placed. The file offset is zero based rather than one based.

The \(\text{FileSeek}\) function returns true on success or false on error.

After using the \(\text{FileSeek}\) function, you will generally want to call one of the \(\text{FileRead}\ldots\) or \(\text{FileWrite}\ldots\) functions to read or update the file contents.

The Figure 135 shows how you can use the \(\text{FileOpenWrite}\) function.


The \(\text{FileRead}\ldots\) and \(\text{FileWrite}\ldots\) functions will advance the file pointer so you do not need to use the \(\text{FileSeek}\) function to read or write sequentially through a file.


The \(\text{FileOpenRead}\) and \(\text{FileOpenWriteTruncate}\) functions will automatically position the file pointer to offset 0. The \(\text{FileOpenWrite}\) function will place the file pointer at the end of the file.