![](/images/backgrounds/286549/hp-sunsoft-pascal-4-0-users-manual-549395101x1.png)
5
There are three ways of sharing variables and routines across units when you compile your program without the
If you declare a variable in two or more separate units and the variable is public in both places, that variable is shared between units. Variables are public by default, unless you compile with the
The program unit,
shrvar_prog.p
The module unit, shrvar_mod.p. The assignment of a new value to global and max_array in the procedure proc in shrvar_prog.p is repeated in shrvar_mod.p.
program shrvar_prog;
var
global: integer;
procedure proc; external;
begin { program body } global := 1;
writeln('From MAIN, before PROC: ', global); proc;
writeln('From MAIN, after PROC: ', global) end. { shrvar_prog }
module shrvar_mod;
var
global: integer;
procedure proc;
begin
writeln('From PROC: ',global); global := global + 1
end; { proc }
Separate Compilation | 77 |