TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>PASCAL</strong> STATE~ENTS<br />
Example 4<br />
:= 1 TO N DO<br />
FOR Effiplo~ee<br />
BEGIN<br />
HRS : :::: 40;<br />
FOR Da~ := Mon TO Fri DO<br />
IF Sick(Employee,Da~J<br />
THEN<br />
HR!:l : :::: HR!3····B,<br />
F' a y [: [ IT! P 1 () y f.;> f:~ J : :::: W a ~J f:'~ [ E III P 1 D ~J e f:.~ ] * HI:;: S<br />
END;<br />
You can combine compound statements as in this example. The inner FOR<br />
statement computes the number of hours each employee worked from<br />
Monday through Friday. The outer FOR statement resets hours to 40 for<br />
each employee and computes each person's pay as the product of w~ge<br />
and hours worked.<br />
5.4.2 The REPEAT Statement<br />
The REPEAT statement groups one or more statements for execution until<br />
a specified condition is true.<br />
Fo rma t<br />
where:<br />
REPEAT statement [;statement ... D UNTIL expression;<br />
expression<br />
specifies a Boolean expression.<br />
Note that the format of the REPEAT statement eliminates the need for a<br />
compound statement.<br />
The expression is evaluated after the statements are executed.<br />
Therefore, the REPEAT group is always executed at least once.<br />
Example<br />
REPEAT<br />
READ(X);<br />
IF (X IN (10 1 •• 1 9 1 ]) THEN<br />
BEGIN<br />
Di~it_Count := Di~it_Count t 1;<br />
Di~it_Sum := Di~it_Sum t ORD(X) - ORD(IOI)<br />
END<br />
ELSE Char_Count := Char_Countt1<br />
UNTIL EOLN(INPUT);<br />
Assume that the variable X is of type Char, and the variables<br />
Digit_Count, Digit_Sum, and Char Count are integers. The example<br />
reads a character (X) from the terminal. If X is a digit, the count<br />
of digits is incremented by one; and the sum of digits is increased<br />
by the value of X. The ORD function is used to compute the value of<br />
X. If X is not a digit, the variable Char Count is incremented by<br />
one. The example continues processing characters from the terminal<br />
until it reaches an end-of-line (EOLN) condition.<br />
5-10