The statement-sequence of the repeat-statement shall be repeatedly executed, except as modified by the execution of a goto-statement, until the Boolean-expression of the repeat-statement yields the value true on completion of the statement-sequence. The statement-sequence shall be executed at least once, because the Boolean-expression is evaluated after execution of the statement-sequence.
The for-statement shall specify that the statement of the for-statement is to be repeatedly executed while a progression of values is attributed to a variable denoted by the control-variable of the for-statement.
The control-variable shall be an entire-variable whose identifier is declared in the variable-declaration-part of the block closest-containing the for-statement. The control-variable shall possess an ordinal-type, and the initial-value and final-value shall be of a type compatible with this type. The initial-value and the final-value shall be assignment-compatible with the type possessed by the control-variable if the statement of the for-statement is executed. After a for-statement is executed, other than being left by a goto-statement, the control-variable shall be undefined. Neither a for-statement nor any procedure-and-function-declaration-part of the block that closest-contains a for-statement shall contain a statement threatening the variable denoted by the control-variable of the for-statement.
A statement S shall be designated as threatening a variable V if one or more of the following statements is true.
a) S is an assignment-statement and V is denoted by the variable-access of S.
b) S contains an actual variable parameter that denotes V.
c) S is a procedure-statement that specifies the activation of the required procedure read or the required procedure readln, and V is denoted by variable-access of a read-parameter-list or readln-parameter-list of S.
d) S is a statement specified using an equivalent program fragment containing a statement threatening V.
Apart from the restrictions imposed by these requirements, the for-statement
for v := e1 to e2 do body
shall be equivalent to
begin
temp1 := e1; temp2 := e2;
if temp1 <= temp2 then
begin
v := temp1; body;
while v <> temp2 do
begin v := succ(v); body end
end
end
and the for-statement
for v := e1 downto e2 do body
shall be equivalent to
begin
temp1 := e1; temp2 := e2;
if temp1 >= temp2 then
begin
v := temp1; body;
while v <> temp2 do
begin v := pred(v); body end
end
end
where temp1 and temp2 denote auxiliary variables that the program does not otherwise contain, and that possess the type possessed by the variable v if that type is not a subrange-type; otherwise the host-type of the type possessed by the variable v.
Examples:
for i := 2 to 63 do if a[i] > max then max := a[i]
for i := 1 to 10 do
for j := 1 to 10 do
begin
x := 0;
for k := 1 to 10 do
x := x + m1[i,k] * m2[k,j];
m[i,j] := x
end
for i := 1 to 10 do for j := 1 to i - 1 do m[i][j] := 0.0
A with-statement shall specify the execution of the statement of the with-statement. The occurrence of a record-variable as the only record-variable in the record-variable-list of a with-statement shall constitute the defining-point of each of the field-identifiers associated with components of the record-type possessed by the record-variable as a field-designator-identifier for the region that is the statement of the with-statement; each applied occurrence of a field-designator-identifier shall denote that component of the record-variable that is associated with the field-identifier by the record-type. The record-variable shall be accessed before the statement of the with-statement is executed, and that access shall establish a reference to the variable during
the entire execution of the statement of the with-statement.
The statement
with v1,v2,...,vn do s
shall be equivalent to
with v1 do
with v2 do
...
with vn do s
Example:
with date do
if month = 12 then begin month := 1; year := year + 1 end
else month := month+1
has the same effect on the variable date as
if date.month = 12 then
begin date.month := 1; date.year := date.year+1 end
else date.month := date.month+1
Input and output
The procedure read
The syntax of the parameter list of read when applied to a textfile shall be
If the file-variable is omitted, the procedure shall be applied to the required textfile input, and the program shall contain a program-parameter-list containing an identifier with the spelling input.
The requirements of this subclause shall apply for the procedure read when applied to a textfile; therein, f shall denote the textfile. The effects of applying read(f,v) to the textfile f shall be defined by pre-assertions and post-assertions within the requirements of 6.6.5.2. The pre-assertion of read(f,v) shall be the pre-assertion of get(f). Let t denote a sequence of components having the char-type; let r, s, and u each denote a value of the sequence-type defined by the structure of the type denoted by text; if u = S( ), then let t = S( ); otherwise, let u.first = end-of-line; let w = f0 or w = f0.R.first, where the decision as to which shall be implementation-dependent; and let r ~s ~t ~u = w ~f0.R.rest. The post-assertion of read(f,v) shall be
(f.M = f0.M) and (f.L ~ f.R = f0.L ~ f0.R) and (f.R = t ~ u) and
(if f.R = S( ) then (f is totally-undefined) else (f = f.R.first)).
NOTE --- 1 The variable-access is not a variable parameter. Consequently, it may be a component of a packed structure, and the value of the buffer-variable need only be assignment-compatible with it.
a) For n>=1, read(f,v1 ,...,vn) shall access the textfile and establish a reference to that textfile for the remaining execution of the statement; each of v1 ,...,vn shall be a variable-access possessing a type that is the real-type, is a string-type, or is compatible with the char-type or with the integer-type. For n>=2, the execution of read(f,v1 ,...,vn) shall be equivalent to
begin read(ff,v1); read(ff,v2 ,...,vn) end
where ff denotes the referenced textfile.
b) If v is a variable-access possessing the char-type (or subrange thereof), the execution of read(f,v) shall be equivalent to
begin v := ff; get(ff) end
where ff denotes the referenced textfile.
NOTE --- 2 To satisfy the post-assertions of get and of read(f,v) requires r = S( ) and length(s) = 1.
c) If v is a variable-access possessing the integer-type (or subrange thereof), read(f,v) shall satisfy the following requirements. No component of s shall equal end-of-line. The components of r, if any, shall each, and (s ~t ~u).first shall not, equal either the char-type value space or end-of-line. Either s shall be empty or s shall, and s ~S(t.first) shall not, form a signed-integer according to the syntax of 6.1.5. It shall be an error if s is empty. The value of the signed-integer thus formed shall be assignment-compatible with the type possessed by v and shall be attributed to v.
NOTE --- 3 The sequence r represents any spaces and end-of-lines to be skipped, and the sequence s represents the signed-integer to be read.
d) If v is a variable-access possessing the real-type, read(f,v) shall satisfy the following requirements. No component of s shall equal end-of-line. The components of r, if any, shall each, and (s ~t ~u).first shall not, equal either the char-type value space or end-of-line. Either s shall be empty or s shall, and s ~S(t.first) shall not, form a signed-number according to the syntax of 6.1.5. It shall be an error if s is empty. The value denoted by the number thus formed shall be attributed to the variable v.
NOTE --- 4 The sequence r represents any spaces and end-of-lines to be skipped, and the sequence s represents the number to be read.