HP Pascal/iX Programmer's Guide (31502-90023)

7- 17
passed.
Example 4
PROGRAM prog (output);
PROCEDURE outer2 (PROCEDURE procvar (v : integer));
BEGIN {outer2}
procvar(7);
END; {outer2}
PROCEDURE outer1 (p : integer);
VAR
x : integer;
PROCEDURE inner (i : integer);
BEGIN {inner}
writeln(x,i,x+i,p);
END; {inner}
BEGIN {outer1}
x := 5;
outer2(inner);
END; {outer1}
BEGIN {prog}
outer1(2);
END. {prog}
The preceding program prints:
5 7 12 2
Because the procedure inner has access to the nonlocal variables x and p
before being passed to outer2, it has access to x and p after being
passed to outer2 (even though x and p are outside the scope of outer2).
Hidden Parameters
Hidden parameters do not appear in formal or actual parameter lists, but
are nevertheless passed to routines. They are always integers.
You must know about hidden parameters in order to debug your program at
the assembly language level, and you must include them in the parameter
lists of external routines that are not written in Pascal. (For
information, see Chapter 9 .)
Table 7-3 shows which routines receive hidden parameters, how many
hidden parameters they receive, where the hidden parameters are in the
physical parameter order, and the values of the hidden parameters.
Table 7-3. Hidden Parameters
------------------------------------------------------------------------------------------------
|||||
| Routine With | Receives | Location of Hidden | Value of [Each] |
|||Parameters in | Hidden Parameter |
|||Physical Order ||
|||||
------------------------------------------------------------------------------------------------
|||||
| ANYVAR parameters | One hidden parameter | Each one follows its | Size in bytes of the |
| | for each ANYVAR | corresponding ANYVAR | actual parameter. |
| | parameter. | parameter. | |
|||||
------------------------------------------------------------------------------------------------
|||||
| Generic string | One hidden parameter | Each one follows its | Maximum length of |
| parameters (not | for each generic | corresponding generic | string. |
| (PACs) | string parameter. | string parameter. | |
|||||
------------------------------------------------------------------------------------------------