Visible to Intel only — GUID: GUID-38F41B08-EAB4-4C6D-A5C3-B7FA10DE8193
Visible to Intel only — GUID: GUID-38F41B08-EAB4-4C6D-A5C3-B7FA10DE8193
REWIND
Statement: Positions a sequential or direct access file at the beginning of the file (the initial point). It takes one of the following forms:
REWIND ([UNIT=] io-unit[, ERR= label] [, IOMSG=msg-var] [, IOSTAT=i-var])
REWIND io-unit
io-unit |
(Input) Is an external unit specifier. |
label |
Is the label of the branch target statement that receives control if an error occurs. |
msg-var |
(Output) Is a scalar default character variable that is assigned an explanatory message if an I/O error occurs. |
i-var |
(Output)Is a scalar integer variable that is defined as a positive integer if an error occurs and zero if no error occurs. |
Description
The unit number must refer to a file on disk or magnetic tape, and the file must be open for sequential, direct, or append access.
If a REWIND is done on a direct access file, the NEXTREC specifier is assigned a value of 1.
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.
Example
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.
The following shows another example:
WRITE (7, '(I10)') int
REWIND (7)
READ (7, '(I10)') int