TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
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 1<br />
IF «X*37/Con~:;tant) + Factor) :> lO()O.O THEN<br />
Answer := Answer - Factor;<br />
If the value of the arithmetic expression is greater than 1000.0, a<br />
new value is assigned to the variable Answer.<br />
Example 2<br />
IF (A :> B) AND ( B ~ C) THEN<br />
D ::::: A···· C;<br />
If both relational expressions are true, n is assigne~ the value of A<br />
- c.<br />
Exampl e 3<br />
IF (Name 'SMITH') AND (INITIAL I ,.J I) THEN<br />
BEGIN<br />
Count := Count + 1;<br />
Add re~:;~:;;<br />
SlTIi thadd[ Count]l ! ::::<br />
WFnTELN ('..} SMITH NO. I,Count, I L.IVE~) AT I AddT'f.-~ss)<br />
This example counts the number of J SMITHs, prints each one's street<br />
address, and stores it in an array.<br />
Exampl e 4<br />
IF Day = Thurs THEN<br />
FOR I := 1 TO MaxEffip DO<br />
Pay[IJ := Salary[IJ * (l-Tax_Rate-FICA);<br />
If the current value of the variable Day is Thurs, the FOR loop is<br />
executed, and values for Pay(I] are computed. If the value of Day is<br />
not Thurs, the FOR loop is not execute~; and program control passes<br />
to the statement following the end of the loop.<br />
5.3.2 The IF-THEN-ELSE Statement<br />
The IF-THEN-ELSE statement is an extension of the IF-THEN statement<br />
that includes an alternative statement, the ELSE clause. The ELSE<br />
clause is executed if the test condition is false.<br />
Fo rma t<br />
where:<br />
IF expression THEN statementl ELSE statement2<br />
expression<br />
specifies a Boolean expression.<br />
sta temen tl denotes the sta tement to be executed if the<br />
exprt=ssion is true.<br />
statement2 denotes the statement to be executed if the<br />
expression is false.<br />
5-5