HP Pascal/iX Reference Manual (31502-90022)

7- 10
When you want to export modules, as well as procedures and types, insert
the reserved word EXPORT following the module name.
When EXPORT is used to specify an export of a module, that module is only
available to the program or module importing the current module.
Syntax
Import_declaration:
Example 1
In this example, module bit_types is defined in another compilation unit
(see example in section "MODULE" ). bit_types is compiled into an
object file called mod1.o. $SEARCH is used because bit_types is not in
the same compilation unit as the main program.
PROGRAM show_import (output);
$SEARCH 'mod1.o'$ { Object file that contains bit_types.}
IMPORT { Import the module bit_types, under }
bit_types; { "Modules", that is needed to }
{ compile this program. }
VAR
A,B: bits8;
BEGIN
A:= 100;
writeln(A);
END.
Example 2
Module show_import_export both imports and exports module bit_types at
the same time. The main program uses type bits8. bits8 is defined in
bit_types, but is available to the main program because[REV BEG] it
imports show_import_export which exports bit_types.
Module show_export is compiled into an object file called mod2.o and
bit_types is compiled into an object file called mod1.o (see section
"MODULE" ). The main program imports module show_import_export only.
However, the $SEARCH statement must include both object files mod1.o and
mod2.p, even thought the main program does not directly import module
bit_types.[REV END]
MODULE show_import_export;
$SEARCH 'mod1.o'$ {Object file that contains bit_types.}
IMPORT
bit_types EXPORT;
EXPORT
TYPE
byte_rec = record;
a, b : bits8
end;