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

Example q<br />

Ase~5<br />

::::: Asps····[ 10+".7J'<br />

Assume that the base type of the set variable Ages is the integer<br />

subrange 0 .. 255. This exampJe assigns the value of the set expression<br />

Ages- rlO+7] to the variable Ages.<br />

5.3 CONDITIONAL STATEMENTS<br />

A conditional statement selects a statement for execution depending on<br />

the value of an expression. <strong>PASCAL</strong> provides three conditional<br />

statements:<br />

• IF-THEN statement<br />

• IF-THEN-ELSE statement<br />

• CASE statement<br />

These are described in the following sections.<br />

5.3.1 The IF-THEN Statement<br />

The IF-THEN statement causes the conditional execution of a statement.<br />

Fo rma t<br />

IF expression THEN statement;<br />

where:<br />

expression<br />

statement<br />

specifies a Boolean expression.<br />

indicates a simple or compound statement.<br />

The statement is executed only if the value of the expression is TRUE.<br />

If the value of the expression is FALSE, program control passes to the<br />

statement following the IF-THEN statement.<br />

The THEN clause can specify a compound statement. However, note that,<br />

if you use the compound statement, you must not place a semicolon<br />

between the words THEN and BEGIN. The example below shows a semicolon<br />

immediately following the word THEN:<br />

IF Da~<br />

BEGIN<br />

= Thurs THEN,<br />

statement<br />

(* misPlaced semicolon *)<br />

END;<br />

As a result of the misplaced semicolon, the empty statement becomes<br />

the object of the THEN clause. In this example, the compound<br />

statement following the IF-THEN statement is executed regardless of<br />

the value of Day.<br />

5-4

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

Saved successfully!

Ooh no, something went wrong!