28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

*ERROR 93 -- the name of the control variable is required here<br />

The name of the variable to be used to control a FOR loop must be specified<br />

immediately following the word FOR.<br />

PROGRAM fail(output);<br />

BEGIN<br />

END.<br />

FOR 1 TO 10 DO (no control variable}<br />

writeln('hello');<br />

*ERROR 94 -- this is not a variable and so may not be used to<br />

control the FOR statement<br />

A FOR statement must use a variable declared in the current block to<br />

control the repeated execution of the controlled statement. This error<br />

indicates that an attempt has been made to use something other than a<br />

variable as the control variable.<br />

PROGRAM fail(output);<br />

TYPE cvar = 1..10;<br />

BEGIN<br />

END.<br />

FOR cvar := 1 TO 10 DO {cvar is not a variable}<br />

writeln('hello');<br />

*ERROR 95 -- the control variable was not declared in<br />

this block<br />

The FOR loop control variable must be a local variable, that is, it must have<br />

been declared in the VAR section of the current block. Note in particular<br />

that a formal parameter to a procedure or function may not be used as a<br />

control variable.<br />

PROGRAM fail(output);<br />

VAR global : integer;<br />

PROCEDURE print; BEGIN<br />

END;<br />

FOR global := 1 to 10 DO (global not declared in 'print'}<br />

writeln('printingg');<br />

78 <strong>Pascal</strong> Issue 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!