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

9- 3
END. {pascal_pascal}
This is the external Pascal procedure:
$EXTERNAL$
PROGRAM PASCALSUB;
VAR
global : integer;
PROCEDURE psubproc ( adder : integer;
VAR total : integer);
VAR
localconstant : integer;
BEGIN {psubproc}
IF (global MOD 2) = 0 THEN
localconstant := adder * 2
ELSE
localconstant := adder;
total := total + localconstant;
END; {psubproc}
BEGIN
END.
You can use the EXTERNAL directive with procedure declarations in the
implement part of a module. In such a procedure declaration, repeating
the formal parameters is optional. If you do repeat them, they must be
identical to those in the export section.
Example 2
MODULE m;
EXPORT
PROCEDURE proc1 (VAR parm1 : integer;
VAR parm2 : char);
PROCEDURE proc2 (VAR parm1 : integer);
IMPLEMENT
PROCEDURE proc1; {formal parameters omitted}
EXTERNAL;
PROCEDURE proc2 (VAR parm1 : integer); {formal parameter repeated}
EXTERNAL;
END;
Use the EXTERNAL directive in exported procedures to link routines
written in other languages into your program. You are responsible for
ensuring that the formal parameters of the exported procedure correspond
to those of the actual external procedure.
NOTE Do not confuse the EXTERNAL directive with the EXTERNAL compiler
option. Refer to the
HP Pascal/iX Reference Manual
or the
HP
Pascal/HP-UX Reference Manual
, depending on your implementation,
for information on the EXTERNAL compiler option.
Calling HP C from HP Pascal
The table and example in this section assume that the HP Pascal program
and the C routine that it calls are both compiled in Native Mode. If the
C routine is in a Compatibility Mode SL instead, you must write a switch
stub to access it from your HP Pascal program (see "Switch Stubs" ).
For more information on C types, please refer to the
HP C Programmer's
Guide
.
Table 9-1 matches corresponding HP Pascal and C types. It contains
only the types that are acceptable for formal intrinsic parameters. The
variable
n
is an integer.