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.

PROGRAM fail;<br />

VAR n : integer;<br />

FUNCTION one:integer;<br />

BEGIN<br />

one := 1; [correct}<br />

END;<br />

BEGIN<br />

n := one; (correct}<br />

one := 1; (incorrect - not inside 'one'}<br />

END.<br />

*ERROR 135 -- function cannot be used in this way<br />

Appendix A<br />

This message is issued when a required function is used as though it were a<br />

variable.<br />

PROGRAM fail;<br />

BEGIN<br />

sqrt := 0;<br />

END.<br />

*ERROR 136 -- the type of the array index does not match the type<br />

given in the array declaration<br />

The expression used to select an element of an array must give a value<br />

which is of the same type as was used to declare the array.<br />

PROGRAM fail(output);<br />

TYPE person = (fred, fill, anne, jim);<br />

VAR who : person;<br />

lucky : ARRAY [person] of Boolean;<br />

BEGIN<br />

IF lucky[who] THEN writeln('yes')<br />

(OK - who is 'person'-type}<br />

IF lucky[true] THEN writeln('no')<br />

[wrong - true is not 'person'-type}<br />

END.<br />

<strong>Pascal</strong> Issue I 93

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

Saved successfully!

Ooh no, something went wrong!