From: J_SCHULL@acc.haverford.edu (Jonathan Schull)
Newsgroups: comp.lang.pascal
Subject: Units using Units
Date: 4 Apr 92 18:19:42 GMT

>Suppose MyProgram Uses UnitShallow;
>Suppose UnitShallow Uses UnitDeep;
>To create MYPROGRAM.EXE, do
>  I need to have UNITDEEP.TPU as well as UNITSHALLOW.TPU,
>  or  can I do it with just MYPROGRAM.PAS and UNITSHALLOW.TPU  ?
>I seem to be needing both, but I want to only need UnitShallow.

(********************************
      Several people suggested that I could have what I want
      if MyProgram doesn't itself use anything in UnitDeep.
      But either I'm confused, or our beliefs are wrong (or both!)
      The compiler really doesn seem to need UNITDEEP.TPU no
      matter what.

      To compile MyProgram, I seem to need UnitDeep no matter
      where the "Uses UnitDeep" statement is put in UnitShallow. 
      (I'm using DRDOS 6.0, but my collaborator has confirmed
      this using MSDOS 5.0)

      Here's the scoop. ********************************)

Volume in drive C is JS NOTEBOOK
Directory of  C:\SL\TEST

.            <DIR>     4-04-92 10:06a
..           <DIR>     4-04-92 10:06a
UNITDEEP PAS       48  4-04-92 10:22a
UNITSHAL TPU      416  4-04-92 10:14a
UNITSHAL PAS       67  4-04-92 10:10a
NOPROB              0  4-04-92 10:23a
UNITDEEP TPU      400  4-04-92 10:22a
MYPROGRA PAS       31  4-04-92  9:58a
HIDE         <DIR>     4-04-92 10:09a
       10 File(s)   8896512 bytes free

C:\SL\TEST>type *.pas

UNITDEEP.PAS:
unit UnitDeep;
interface
implementation
end.

UNITSHAL.PAS:
unit UnitShallow;
interface
implementation
uses unitDeep;
end.

MYPROGRA.PAS:
Uses UnitShallow;
begin
end.

C:\SL\TEST>tpc myprogram
Turbo Pascal Version 5.5  Copyright (c) 1983,89 Borland International
MYPROGRAM.PAS(3)
3 lines, 0.7 seconds, 1200 bytes code, 646 bytes data.



 Volume in drive C is JS NOTEBOOK
 Directory of  C:\SL\TEST

.            <DIR>     4-04-92 10:06a
..           <DIR>     4-04-92 10:06a
UNITDEEP PAS       48  4-04-92 10:22a
UNITSHAL TPU      416  4-04-92 10:14a
UNITSHAL PAS       67  4-04-92 10:10a
NOPROB   TXT      843  4-04-92 10:30a
UNITDEEP TPU      400  4-04-92 10:22a
MYPROGRA PAS       31  4-04-92  9:58a
MYPROGRA EXE     1312  4-04-92 10:26a
HIDE         <DIR>     4-04-92 10:09a

(********************************
      OK, no problem.  But now....
          ********************************)

C:\SL\TEST>del unitdeep.*

C:\SL\TEST>tpc myprogram
Turbo Pascal Version 5.5  Copyright (c) 1983,89 Borland International
MYPROGRAM.PAS(1): Error 15: File not found (UNITDEEP.TPU).
Uses UnitShallow;
                ^
(********************************
      Well, maybe I need to revise UnitShallow....
          ********************************)


C:\SL\TEST>type unitsh*.pas

UNITSHAL.PAS:
unit UnitShallow;
interface
uses unitDeep; {USES STATEMENT MOVED INTO INTERFACE}
implementation
end.

(********************************
      restore UnitDeep in directory, and recompile UnitShallow
          ********************************)

C:\SL\TEST>tpc unitshallow
Turbo Pascal Version 5.5  Copyright (c) 1983,89 Borland International
UNITSHALLOW.PAS(5)
5 lines, 0.3 seconds, 0 bytes code, 0 bytes data.

C:\SL\TEST>tpc myprogram
Turbo Pascal Version 5.5  Copyright (c) 1983,89 Borland International
MYPROGRAM.PAS(3)
3 lines, 0.5 seconds, 1216 bytes code, 646 bytes data.

(********************************
    Again, no problem with UnitDeep present, but...
          ********************************)


C:\SL\TEST>del unitdeep*.*

C:\SL\TEST>tpc myprogram
Turbo Pascal Version 5.5  Copyright (c) 1983,89 Borland International
MYPROGRAM.PAS(1): Error 15: File not found (UNITDEEP.TPU).
Uses UnitShallow;
                ^
(********************************
    So what's going on?  Why does the compiler need UNITDEEP.TPU?
          ********************************)