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

9- 2
SPL The source code of the external routine is SPL, without
option variable parameters. The compilation unit that
makes the call must also contain the compiler option
HP3000_16 (see compiler options in the
HP Pascal/iX
Reference Manual
or the
HP Pascal/HP-UX Reference
Manual
). See Table 9-4 for corresponding HP Pascal
and SPL types.
SPL VARIABLE The source code of the external routine is SPL, with
optional variable parameters. You must specify SPL
VARIABLE (rather than SPL) if the external routine has
option parameters, even if you do not omit parameters
when you call the routine. The compilation unit that
makes the call must also contain the compiler option
HP3000_16 (see compiler options in the
HP Pascal/iX
Reference Manual
or the
HP Pascal/HP-UX Reference
Manual
). See Table 9-4 for corresponding HP Pascal
and SPL types.
The programmer is responsible for matching the formal parameters and
result type of the routine containing the EXTERNAL directive with the
formal parameters and result type of the external routine. The matching
rules are:
* Corresponding formal parameter lists must have the same number of
parameters in the same order.
* Corresponding formal parameters must be of corresponding types.
(Correspondence depends upon the source language of the external
routine. See the parameter descriptions, below.)
* Corresponding formal parameters can have different names.
The INTRINSIC directive is more flexible about matching. See Chapter 10
for details.
The EXTERNAL directive replaces the block in a routine declaration (see
the
HP Pascal/iX Reference Manual
or the
HP Pascal/HP-UX Reference Manual
for details). The declaration containing the EXTERNAL directive can be
at any level, but the external routine itself must be at level one in its
own compilation unit.
Example 1
The Pascal program Pascal_Pascal calls the external Pascal procedure
psubproc. This is the program:
$GLOBAL$
PROGRAM Pascal_Pascal(output);
CONST
looplimit = 10;
TYPE
loopbound = 1..looplimit;
VAR
loop : loopbound;
global,
dynamic,
static : integer;
PROCEDURE psubproc ( parm1 : integer;
VAR parm2 : integer); EXTERNAL;
BEGIN {pascal_pascal}
dynamic := 0;
FOR loop := 1 to looplimit DO BEGIN
IF loop <= 5 THEN
static := 10
ELSE
static := 20;
global := loop;
psubproc(static,dynamic);
write('Cycle = ', loop, 'Total = ', dynamic);
END;
write('Finish processing');