5.4.5.3 Seek Statement

A <seek-statement> repositions where the next operation on a <file-number> will occur within that file.

 seek-statement = "Seek" file-number "," position  
 position = expression  

Static Semantics:

§ The declared type (section 2.2) of <position> MUST be a scalar declared type (section 2.2).

Runtime Semantics:

§ An error (number 52, "Bad file name or number") is raised if the file number value (section 5.4.5.1.1) of <file-number> is not a currently-open (section 5.4.5.1) file number (section 5.4.5).

§ The new file position is the evaluated value of <position> Let-coerced to declared type Long.

§ An error is raised if the new file position is 0 or negative.

§ If the <open-statement> for the file number value of <file-number> had <mode> Random, then the file-pointer-position’s location refers to a record; otherwise, it refers to a byte.

If new file position is greater than the current size of the file (measured in bytes or records depending the <mode> of the <Open-statement> for the file number value), the size of the file is extended such that its size is the value new file position. This does not occur for files whose currently-open <access> is Read. The extended content of the file is implementation defined any can be undefined.

§ The file-pointer-position of the file is set to new file position.