qbasic.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
SEEK Function and Statement
  Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
The SEEK function returns the current file position.
The SEEK statement sets the file position for the next read or write.
 
SEEK(filenumber%)
SEEK [#]filenumber%, position&
 
    ■ filenumber%    The number of an open file.
    ■ position&      The position where the next read or write occurs. For
                     random-access files, a record number. For other files,
                     the byte position relative to the beginning of the file.
                     The first byte is at position 1.
 
Example:
    OPEN "TEST.DAT" FOR RANDOM AS #1
    FOR i% = 1 TO 10
        PUT #1, , i%
    NEXT i%
    SEEK #1, 2
    GET #1, , i%
    PRINT "Data: "; i%; " Current record: "; LOC(1); " Next: "; SEEK(1)
 
See Also    GET, PUT    OPEN