28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5<br />

PROGRAM warn(output);<br />

LABEL 1;<br />

PROCEDURE jump; BEGIN<br />

END;<br />

BEGIN<br />

GOTO 1;<br />

jump;<br />

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

END.<br />

Warning 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 />

Warning 89 -- the case statement did not include all possible cases<br />

A case statement has been found which has not provided a meaning for all<br />

the possible values of the case selector. When this occurs in a RECORD<br />

definition it is an error. When it occurs in a CASE statement it is only a<br />

warning, however if the case selector takes one of the unspecified values<br />

during execution a run-time error will be reported.<br />

24 <strong>Pascal</strong> Issue 1

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

Saved successfully!

Ooh no, something went wrong!