78
Pascal 4.0 User’s Guide
5
Using
extern
Option to Share Routines
If a program or module calls a procedure not defined in that unit, you must
declare it with either the
extern
or
external
routine option. For instance, in
the previous example, the procedure
proc
is defined in
shrvar_mod.p
, but
used in
shrvar_prog.p
. Thus, it is declared as
external
in
shrvar_prog.p
. Also,
proc
must also be defined as public in
shrvar_mod.p
, which is the default.
Using
include
Files to Share Variables and Routines
The
include
file contains the declarations for the program. Placing all
program declarations in a single file makes your program more consistent and
easier to maintain.
To use this feature, place the number sign character (
#
) in the first position of a
line immediately followed by the word
include
, and then a file name
enclosed in angle brackets (
<
and
>
) or double quotation marks (
"
). The
different enclosures (
<>
and
""
) affect the search order for files. The syntax for
the
#include
directive is determined by
cpp
(1).
When the compiler encounters the
#include
in the input, it inserts the lines
from the included file into the input stream.
The commands to compile and
execute
shrvar_prog.p
and
shrvar_mod.p
hostname% pc shrvar_prog.p shrvar_mod.p
shrvar_prog.p:
shrvar_mod.p:
Linking:
hostname% a.out
From MAIN, before PROC: 1
From PROC : 1
From MAIN, after PROC : 2
Summary of Contents for SunSoft Pascal 4.0
Page 14: ...xiv Pascal 4 0 User s Guide ...
Page 16: ...xvi Pascal 4 0 User s Guide ...
Page 30: ...6 Pascal 4 0 User s Guide 1 ...
Page 160: ...136 Pascal 4 0 User s Guide 6 ...
Page 268: ...244 Pascal 4 0 User s Guide 11 ...
Page 320: ...296 Pascal 4 0 User s Guide B ...
Page 331: ...Index 307 ...
Page 333: ......