Re: Specifying path to a non standard package
- To: mathgroup at smc.vnet.net
- Subject: [mg59366] Re: Specifying path to a non standard package
- From: albert <awnl at arcor.de>
- Date: Sun, 7 Aug 2005 03:46:59 -0400 (EDT)
- References: <dd1ikr$1cc$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, > -- I am using a package "SubscriptSymbols" in a notebook, with the > statement: Needs["Utilities`SubscriptSymbols`"]; I was almost expecting that you would come up with questions like these after seeing your first post :-) > I must have the SubscriptSymbols.m file in the > same directory as the notebook that uses it. > Question > -- How can I load the package from a specified working directory that is > not part of the context paths known by mathematica? I've tried adding > path info within the needs statement but that does not work. The variable $Path is a list of directories where the kernel looks for packages, so inculding yourworkdirectory in that list will make the kernel find the file: PrependTo[$Path,{"yourworkdirectory"}]; Since "." (current work directory) is usually also part of $Path it might also work to just SetDirectory["yourworkdirectory"] before calling Needs. A pitfall is that the package you use wants to be a 'subpakage' of Utilities so it will not load correctly unless you put it into a subdirectory Utilites of your workdirectory so that a recursive listing of yourworkdirectory will look like this: mymathfiletorun.m Utilitis/ Utilities/SubscriptSymbols.m now if you say: PrependTo[$Path,{"yourworkdirectory"}]; Needs["Utilities`SubscriptSymbols.m"]; in mymathfiletorun.m (or mymathnotebook.nb) it should work. If you can't make new subdirectories within your workdirectory, you will need to edit the SubscriptSymbols.m file so that it does not think to be part of Utilities. Usually you will only need to edit the BeginPackage-Call within that file from BeginPackage["Utilities`SubscriptSymbols`"] to: BeginPackage["SubscriptSymbols`"] and of course put it right into workdirectory (no subdirectory) and load it with Needs["SubscriptSymbols`"] after that change. Changing the package from Utilities`SubscriptSymbols` to SubscriptSymbols` might become more complicated, depending on what the package is doing. If you are not experienced with how packages and contexts work in mathematica it might take you some time to find out what will be needed to change in that case so I would not recommend to do it if there are other possibilities... good luck, Albert