ISO Pascal reference manual
ISO Pascal reference manual
ISO Pascal reference manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
END.<br />
FOR w := sun TO fri DO writeln('day'); (not in range}<br />
FOR w := 1 TO fri DO writeln('day'); (wrong type}<br />
*ERROR 99 -- the final value cannot be assigned to <br />
The final value of a FOR loop cannot be assigned to the loop control<br />
variable < name > because it is not of a suitable type or not in the correct<br />
range.<br />
PROGRAM fail(output);<br />
TYPE days = (sun, mon, tue, wed, thurs, fri, sat);<br />
week = mon..fri;<br />
VAR w : week;<br />
BEGIN<br />
END.<br />
FOR w := mon TO sat DO writeln('day'); (not in range}<br />
FOR w := mon TO 7 DO writeln('day'); [wrong type}<br />
*ERROR 100 -- a procedure or function contains a statement which<br />
threatens to alter the loop control variable <br />
Note that this error is commuted into a warning if the EXTEND option is<br />
specified.<br />
The variable which is used to control the execution of a FOR statement<br />
may not be used inside a procedure or function in such a way as to threaten<br />
to alter it, even if the variable will not in fact be altered during the execution<br />
of the loop.<br />
PROGRAM fail(output);<br />
VAR x : integer;<br />
PROCEDURE proc;<br />
BEGIN<br />
END;<br />
BEGIN<br />
END.<br />
X := 0 (this is the threatening statement}<br />
FOR x := 1 to 10 DO writeln('hello'); [incorrect}<br />
80 <strong>Pascal</strong> Issue 1