SEEK function

Purpose

Return the location within a file where the next I/O operation will take place.

Syntax

position&& = SEEK([#] filenum&)

Remarks

If file filenum& was opened in random-access mode, SEEK returns the record number of the next record to be written or read as a Quad-integer (64-bit) value.  If the file was opened in any other mode, SEEK returns the byte position of the next byte to be written or read, as a Quad-integer (64-bit) value.  The Number symbol (#) is optional, but recommended for clarity.

The beginning byte position (for binary and sequential files) or record position (for random-access files) may be 0 or 1, depending on the BASE option used when the file was initially Opened.  The default, if no BASE is specified, is a starting position of 1.

PowerBASIC recommends using the SEEK function over the (more complex) LOC function used in prior versions of PowerBASIC.  LOC remains supported for compatibility with older versions of BASIC, but it is likely that LOC may be removed in future versions of PowerBASIC.

See also

EOF, FILEATTR, GET$, LOC, LOF, OPEN, PUT$, SEEK statement

Example

RANDOMIZE TIMER

OPEN "OUTPUT.TXT" FOR OUTPUT AS #1

PRINT #1, STRING$(RND * 80, RND * 255);

position&& = SEEK(1)

CLOSE #1