13.7 REWIND Statement

The REWIND statement positions a sequential file at the beginning of the file (the initial point). It takes one of the following forms:

 REWIND ([UNIT=]io-unit [,ERR=label] [,IOSTAT=i-var])
 REWIND io-unit
io-unit
Is an external unit specifier.
label
Is the label of the branch target statement that receives control if an error occurs.
i-var
Is a scalar integer variable that is defined as a positive integer if an error occurs and zero if no error occurs.

Rules and Behavior

The unit number must refer to a file on disk or magnetic tape, and the file must be open for sequential or append access.

On DIGITAL UNIX systems, a REWIND statement must not be specified for a file that is open for direct access. On Windows 95 and Windows NT systems, it is allowed if the appropriate compiler option is specified. For more information, see your Programmer's Guide.

If a file is already positioned at the initial point, a REWIND statement has no effect.

If a REWIND statement is specified for a unit that is not open, it has no effect.

Examples

The following statement repositions the file connected to I/O unit 3 to the beginning of the file:

REWIND 3

Consider the following statement:

REWIND (UNIT=9, IOSTAT=IOS, ERR=10)

This statement positions the file connected to unit 9 at the beginning of the file. If an error occurs, control is transferred to the statement labeled 10, and a positive integer is stored in variable IOS.

For More Information:


Previous Page Next Page Table of Contents