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.
PROCEDURES AND FUNCTIONS<br />
variable section<br />
declares local v~riables.<br />
procedure-and-function section<br />
declares local procedures and functions.<br />
s ta temen t<br />
specifies<br />
procedure<br />
5.<br />
an action to be performed by the procedure. A<br />
can contain any of the statements described in Chapter<br />
A procedure consists of a heading and a block. The procedure block is<br />
similar in structure and contents to the main program block, with the<br />
following exceptions:<br />
• The declaration section cannot contain VALUE initializations.<br />
• The procedure block ends with END followed by a semicolon<br />
(i), rather than a period (.) as in the main program. The<br />
procedure does not have a block if it is a forward<br />
declaration or is defined externally (EXTERNAL or FORTRAN).<br />
You must declare all the variables that are local to the procedure,<br />
but you should not redeclare the formal parameters or the procedure<br />
identifier as variable, type, or constant identifiers.<br />
For the two examples that follow, assume that these declarations have<br />
been made:<br />
CONST NUMBER = <strong>20</strong>;<br />
TYPE Range = 0 •• 100;<br />
List = ARRAY[l •• NUMBERJ OF Ran~e;<br />
VAR ARF~<br />
Example 1<br />
: List;<br />
Min i IlIU Ill' M<br />
Ave T'age : r~EAI...;<br />
a ~·d III u tTl<br />
PROCEDURE READ_WRITE (VAR A List);<br />
VAR I : INTEGER;<br />
BEGIN<br />
WRITELN ('Type a list of <strong>20</strong> integers',<br />
'in the range of 0 to 100.');<br />
FOR I := 1 TO Number DO<br />
BEGIN<br />
READCA[IJ);<br />
WRITE(A(IJ!7);<br />
WRITELN<br />
END<br />
END;<br />
The procedure READ WRITE reads a list of<br />
into the array A,-and writes the array.<br />
parameter, the array A.<br />
<strong>20</strong> integers, inserts them<br />
READ WRITE uses one variable<br />
Given the declaration of ARR, the following is a valid procedure call:<br />
READ_WRITECARR);<br />
6-30