MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Finding the Path to the Active Notebook


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12643] Re: [mg12526] Re: Finding the Path to the Active Notebook
  • From: gwinn@ma.ultranet.com (Joe Gwinn)
  • Date: Sat, 30 May 1998 17:36:35 -0400
  • Organization: Gwinn Instruments
  • References: <6kdol7$9vo@smc.vnet.net>

Great!  One more question:  How do you say "calling notebook" (without
actually naming it), so if the notebook is renamed, one can still get
the full pathname without having to revise the notebook code?

Joe Gwinn


In article <6kdol7$9vo@smc.vnet.net>, Reinhold Kainhofer
<reinhold.kainhofer@kfunigraz.ac.at> wrote:

> Paul Abbott wrote:
> 
> > Adalbert Hanszen wrote:
> >
> > > Does anybody know a way, how to programmatically find out, from which
> > > directory the active notebook was loaded?
> > >
> > > I am looking for something like MyOwnPath[] returning me the full path
> > > to the active notebook (or None, if the notebook has just been typed in
> > > without any Notebook-loading).
> >
> > Do you really need this. Doesn't SelectedNotebook[] provide the
> > functionality you need for working with a particular Notebook?
> 
> If you want to work with a particular notebook, it is not necessary, but
> if you need to load any other file located in the same directory as the
> current notebook (e.g. a template for an output to another file), you
> need the path (because the current working directory can be set to any
> other directory as well).
> 
> 
> There is an undocumented Mathematica function which gives the
> Information needed: NotebookInformation
> 
> If you want the Filename of the Notebook as a string, you can define the
> following function:
>
NBFileName[nb_NotebookObject]:=ToFileName@("FileName"/.NotebookInformation[nb]/.{"FileName"->""});
> 
> Now NBFileName[SelectedNotebook[]] returns the filename of the selected
> Notebook.
> 
> 
> If you just want the Path of the notebook, the following will do that:
>
NBPath[nb_NotebookObject]:=ToFileName@("FileName"/.NotebookInformation[nb]/.{"FileName"->""})[[1]];
> 
> NBPath[SelectedNotebook[]]
> 
> If the Notebook has not yet been saved, the returned string is empty.
> 
> 
> Another problem, which I have not been able to solve yet is how to get
> the path where a PACKAGE is located. ContextToFileName does not give
> the whole path. So I cannot open a file that is located in that
> directory by using OpenRead.
> Does anyone know a solution?
> 
> Reinhold
> ____________________________________________________________________
> Reinhold Kainhofer  | e-mail: reinhold.kainhofer@kfunigraz.ac.at
> Strassoldog. 4/3/17 | http://www.cryogen.com/rk 8010 Graz, Austria  |
> http://www.geocities.com/Athens/9145



  • Prev by Date: Re: About plotting a surface
  • Next by Date: Missing link
  • Prev by thread: Re: Re: Finding the Path to the Active Notebook
  • Next by thread: CodeWarrier 3.0 and MathLink?