IMPORT [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
IMPORT
This reserved word indicates which modules are needed to compile a
program or module. The IMPORT section is used to name all other modules
upon which the present one depends. One module, m1, depends on another,
m2, if m1 makes use of the objects exported from m2. For instance, m1
calls procedures in m2, or assigns to m2's variables, or declares
variables of a type exported from m2. There is no IMPORT section if the
module is independent of all other modules.
You must use $SEARCH to import a non-standard module that is not defined
within the same compilation unit that contains the import statement. See
"SEARCH" for more information.
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;
IMPLEMENT
END.
PROGRAM show_import_export_prog (output);
$SEARCH 'mod1.o, mod2.o'$ {Object files that contain bit_types}
{and show_import_export. }
IMPORT
show_import_export;
VAR
little_bit : bits8; { bits8 is defined in module bit_types }
little_byte : byte_rec; {byte_rec is defined in module show_import_export}
BEGIN
little_bit := 9;
little_byte := little_bit;
END.
MPE/iX 5.0 Documentation