31.12.2013 Views

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

TOPS-20 PASCAL Language Manual - Bitsavers

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.

<strong>PASCAL</strong> STATEMENTS<br />

where:<br />

case selector<br />

specifies an expression that evaluates to any<br />

scal~r type except a real type.<br />

case-label list specifies one or more constants of the same<br />

type as the case selector, separated by<br />

commas.<br />

Each case-label list is associated with a statement that may be<br />

executed. The list contains the value of the case-selector expression<br />

for which the system executes the associated statement. You can<br />

specify the case labels in any order. However, the difference between<br />

the largest and smallest labels must not exceed 1000. Each case label<br />

can appear only once within a CASE statement, but can appear in other<br />

CASE statements.<br />

At run time, the system evaluates the case-selector expression and<br />

chooses which statement to execute. If the value of the case-selector<br />

expression does not appear in any case-label list, the system executes<br />

the statement in the OTHERWISE clause.<br />

If the value of the case-selector expression does not match one of the<br />

case labels and you omit the OTHERWISE clause, the status of the CHECK<br />

run-time option determines the action that the system takes. Refer to<br />

Section 8.4.3 for run-time options. If CHECK is enabled, the system<br />

prints an error message and terminates execution. If CHECK is not<br />

enabled, execution continues with the statement following the CASE<br />

statement.<br />

Example 1<br />

CASE Ase OF<br />

END~<br />

5,6 IF Birth_Month> Se? THEN Grade l= 1 ELSE Grade != 0;<br />

7 BEGIN<br />

Grade := 2;<br />

ReadinS_Skill := TRUE<br />

END;<br />

8 Grade:= 3<br />

At run time, the system evaluates Age and executes one of the<br />

statements. If Age is not equal to 5, 6, 7, or 8, and the CHECK<br />

option is enabled, an error occurs and execution is terminated.<br />

Example 2<br />

CASE Ase OF<br />

5,6 IF Birth_Month> Be? THEN Grade != 1 ELSE Grade := 0;<br />

7 BEGIN<br />

Grade != 2;<br />

ReadinS_Skill := TRUE<br />

END;<br />

8 ! Grade := 3<br />

OTHERWISE Grade := 0<br />

An OTHERWISE clause is added in this example. If the value of Age is<br />

not 5, 6, 7, or 8, the value a is assigned to the variable Grade.<br />

5-7

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

Saved successfully!

Ooh no, something went wrong!