Re: NotebookDirectory for package (.m) files?
- To: mathgroup at smc.vnet.net
- Subject: [mg110466] Re: NotebookDirectory for package (.m) files?
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Sun, 20 Jun 2010 03:43:37 -0400 (EDT)
- References: <hviao8$h51$1@smc.vnet.net>
Hi,
> i would like to create an application package that included a data
> directory that can should be accessable for commands in the
> application. Of course I can hard-code the path in my .m file but what
> is the proposed way to do this in case I would like to provide the
> package to other users which might install the package in a completely
> different directory?
Actually I don't know if or what the recommended way to handle this is,
but what I have done and what seems to work but is a little complicated
is this:
1) find where your package is installed (Assuming your package is called
MyPackage and will be loaded with e.g. Needs["MyPackage`"]):
installdir=First[FindFiles["MyPackage",$Path]]
2) now construct the path to your data directory from that path and save
it to a global variable:
$MyPackageDataDirectory=FileNameJoin[{installdir,"Data"}]
there are some pitfalls like which package will be used if you happen to
have more than one installed etc., which you might want to handle or not...
hth,
albert