Of course there is a bit of an ambiguity as to which David you are responding to ;-) !
But the approach of using the 2-argument form of BeginPackage
is tried and true -- it has worked for us for about 25 years since version 1 of Mathematica. And, indeed, it just worked for me now.
I am attaching two packages, TestPackage1 and TestPackage2. They each have one function, TestPackage1
and TestPackage2
respectively. The function TestPackage1
depends on TestPackage2
.
If both are placed in a directory called dir
and one then appends dir
to $Path
using
$Path=AppendTo[$Path,dir]
or, more simply, if you simply put both packages in this directory
FileNameJoin[{$UserAddOnsDirectory, "Applications"}]
which you can open using
SystemOpen[FileNameJoin[{$UserAddOnsDirectory, "Applications"}]]
Then execute
Needs["TestPackage1`"]
and all works fine. One gets
In[4]:= TestPackage1[x]
Out[4]= Sin[x]
and life (an Mathematica) is problem-free from then on (at least in this small universe.
Attachments: