(*  This program demonstrates the overlay facility *)
(*  The link parameters are as follows:
	LINKMT PROG,PASLIB/S/V1:2500/R:297F/D:A80
	LINKMT PROG.001=PROG/O:1,MOD1,PASLIB/S/P:2500
	LINKMT PROG.002=PROG/O:2,MOD2,PASLIB/S/P:2500    *)

PROGRAM DEMO_PROG;

VAR
  I : INTEGER;  (* TO BE ACCESSED BY THE OVERLAYS *)
  CH: CHAR;

EXTERNAL [1] PROCEDURE OVL1; (* COULD HAVE HAD PARAMETERS *)

EXTERNAL [2] PROCEDURE OVL2; (* ALSO COULD HAVE HAD PARAMETERS *)

(* EITHER COULD ALSO HAVE BEEN A FUNCTION IF DESIRED *)

BEGIN
  REPEAT
    WRITE('Enter character, A/B/Q: ');
    READ(CH);
    CASE CH OF
      'A','a' : BEGIN
                  I := 1;    (* TO DEMONSTRATE ACCESS OF GLOBALS *)
                  OVL1       (* FROM AN OVERLAY *)
                END;

      'B','b' : BEGIN
                  I := 2;
                  OVL2
                END
    ELSE
      IF NOT(CH IN ['Q','q'])THEN
        WRITELN('Enter only A or B')
    END (* CASE *)
  UNTIL CH IN ['Q','q'];
  WRITELN('End of program')
END.
