I have created a package following the tutorial in Mathematica 8 virtual book. However this tutorial is quite, let's call it, "short". I have a TestPackage.m
file:
BeginPackage["TestPackage`"];
TestPackage::usage = "Test package"
Begin["`Private`"]
TestPackage[1] := {1}
(*private functions and stuff*)
Mesg := Print["Private function of TestPackage"]
End[]
TestPackage` f[x_] := Module[{a = 3, b = 3}, Mesg; a x^b]
EndPackage[]
and a file UseTestPackage.nb
that uses the package:
ClearAll["Global`*"]
dir = "C:/...and so on"
Get["TestPackage`", Path -> dir]
f[2] (*this should give an output defined in TestPackage.m, but it doesn't*)
$ContextPath
(* {"PacletManager`", "WebServices`", "System`", "Global`"}*)
(*seems it didn't read the m file*)
but nothing happens. No symbols of functions are exported, despite the fact that Get[]
doesn't throw an error.
How do I make it work?
$UserBaseDirectory/Applications
, at least temporarily. I suspect that you don't really load it. $\endgroup$Names["TestPackage`*"]
- you should get{"TestPackage
f"}` or simply{"f"}
if the package has been loaded. $\endgroup$Get
should have complained. $\endgroup$