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(input, output);<br />

TYPE t = 1..3;<br />

VAR x : t;<br />

BEGIN<br />

read(x);<br />

CASE x of<br />

1: writeln('one');<br />

2: writeln('two');<br />

3: writeln('three');<br />

2: writeln('oops!'); [duplicate 2:1<br />

END.<br />

END;<br />

*ERROR 85 -- this case label is out of range<br />

Surprisingly, the <strong>Pascal</strong> standard does not proscribe the specification of case<br />

labels which are outside the range of the case selector except when the<br />

CASE is used to define record variants.<br />

PROGRAM fail(output,input);<br />

TYPE small = 1..3;<br />

rec = RECORD CASE s:small OF<br />

VAR tiny:small;<br />

BEGIN<br />

END.<br />

read(tiny);<br />

CASE tiny OF<br />

END;<br />

END;<br />

1: writeln('one');<br />

2: writeln('two');<br />

3: writeln('three');<br />

1: (a:integer);<br />

2: (b:char);<br />

3: (c:real);<br />

4: (d:boolean); [error 4 is not in small}<br />

4: writeln('four'); (warning 4 is not in small}<br />

74 <strong>Pascal</strong> Issue 1

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

Saved successfully!

Ooh no, something went wrong!