Skip to content

Seek Statement

Paul Squires edited this page Oct 19, 2026 · 2 revisions

Home › File I/O Functions › Seek (Statement)

Seek (Statement)

Sets the 1-based position of the next read or write: bytes, or records for Random.

Syntax

Seek [#]filenum, position

Parameters

  • filenum
  • position

Description

Sets the position at which the next read or write operation on a file will occur.

The position is given in records if the file was opened in Random access mode, in bytes in any other case. The position is 1 based -- the first record of a file is at position 1.

The Seek function is used to get the position of the next read or write operation.

Remarks

Differences from QB

  • None

See also

Examples

' e.g. if you want to skip to the 100th byte in the file for reading/writing:

Dim f As Long

f = FreeFile

Open "file.ext" For Binary As #f

Seek f, 100

Close #f

Category: File I/O Functions
Kind: statement


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally