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 />
Data items declared in any particular block of a <strong>PASCAL</strong> program are<br />
considered global to all its nested subprograms. Thus, d~ta items<br />
declared in the main program block are global to alJ subprograms. A<br />
subprogram can access its global identifiers. For example, the<br />
function SYMMETRY above has no local variables. Tt uses the global<br />
identifiers K and L, and the parameters A and Side, which are declared<br />
in PRINT SYM ARRAY.<br />
6.3 PARAMETERS<br />
Subprograms communicate data with the main program and with each other<br />
by means of parameters. A subprogram can have any number of<br />
parameters, but need not have any at all.<br />
The subprogram heading lists the forma] parameters, which specify the<br />
type of data that will be passed to the subprogram. For example, the<br />
formal parameter list for the procedure PRINT SYM ARRAY is the<br />
following:<br />
(VAR A ARR; Side: INTEGER)<br />
This Jist specifies two parameters to be passed to PRINT SYM ARRAY:<br />
the variable A of the previously defined type ARR, and the-~al~e Side<br />
of type INTEGER.<br />
Each formal parameter corresponds to an actual parameter, specified in<br />
the subprogram call. For example, a valid procedure call to<br />
PRINT_SYM_ARRAY is the following:<br />
This procedure call passes the variable Current Arr and the value of<br />
Current Side to PRINT SYM ARRAY.<br />
The formal parameters are identifiers used in the subprogram; they<br />
represent the actual parameters in each subprogram call. You can call<br />
a subprogram several times with different actual parameters. At<br />
execution, each formal parameter represents the variable or value of<br />
the corresponding actual parameter. The formal-value parameters, and<br />
the actual parameters to which they correspond, must be of identical<br />
types.<br />
6.3.1 Formal Parameters<br />
The formal parameter list specifies the identifier for each parameter<br />
and the type of each parameter to be used within the subprogram.<br />
Format<br />
( [mechanism specifier ]<br />
[ [ mechanism specifier]<br />
identifier list<br />
identifier list<br />
type;<br />
type .•. ] );<br />
n-21