Sets the position for the next read/write operation within a file opened using the Open statement.
Seek [#]filenumber, position |
The Seek statement syntax has the following parts:
Part | Description |
filenumber | Required. Any valid file number. |
position | Required. Number in the range 1 – 2,147,483,647, that indicates where the next read/write operation should occur. |
Record numbers specified in Get and Put
statements override file positioning performed by Seek.
Performing a file-write operation after a Seek operation beyond
the end of a file extends the file. If you attempt a Seek operation to
a negative or zero position, an error occurs.
In this example the Seek statement sets a new position in the file for the next read/write operation.
Dim MaxSize, NextChar, MyChar Open "TESTFILE" For Input As #1 ' Opens file for reading. MaxSize = LOF(1) ' Determines file size in bytes. ' Subsequently reads all records starting from the last one. For NextChar = MaxSize To 1 Step -1 Seek #1, NextChar ' Specifies the byte number. MyChar = Input(1, #1) 'Reads symbol. Next NextChar Close #1 ' Closes file. |
See Also |
Recording Data in a File, Get Statement, Open Statement, Put Statement, Loc Function, Seek Function |