HP SunSoft Pascal 4.0 Manuale Utente Pagina 101

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 333
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 100
Separate Compilation 77
5
Compiling without the -xl Option
There are three ways of sharing variables and routines across units when you
compile your program without the –xl option.
Sharing Public Variables
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 -xl option, in which case
variables are private by default. In this example, the variable global is
public by default, and thus shared between the program and the module.
The program unit,
shrvar_prog.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 }
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.
module shrvar_mod;
var
global: integer;
procedure proc;
begin
writeln('From PROC: ',global);
global := global + 1
end; { proc }
Vedere la pagina 100
1 2 ... 96 97 98 99 100 101 102 103 104 105 106 ... 332 333

Commenti su questo manuale

Nessun commento