MathGroup Archive 2005

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

Search the Archive

Re: Portable Notebooks and Filenames[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57946] Re: Portable Notebooks and Filenames[]
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Mon, 13 Jun 2005 05:51:11 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <d8e4e7$gik$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <d8e4e7$gik$1 at smc.vnet.net>, frank <frank at kuesterei.ch> 
wrote:

> in our group we are using Mathematica both on Windows and on Linux (and
> I'm about to convert a MacAddict to Mathematica).  

A MacAddict to Mathematica? Many Mac addicts (I assume that this is what 
you mean) are already Mathematica users.

> However, we are facing one problem with external file names.
> 
> It is possible to use 
> 
> In[1]:=
> SetDirectory["some/directory/subdirectory"];
> 
> (from a syntax point of view; of course the beginning of the string will
> be different, like ~/netdrive vs. w:)

There are a number of global directory names, designed so that 
machine-independent filenames can be constructed:

  $AddOnsDirectory
  $UserAddOnsDirectory
  $BaseDirectory
  $HomeDirectory 
  $InitialDirectory 
  $TopDirectory
  $RootDirectory

Most likely you will want to use $AddOnsDirectory or 
$UserAddOnsDirectory. 

> On the other hand, this works only on Linux:
> 
> In[2]:=FileNames["subdir/*"]
> 
> while on Windows, only this construct works:
> 
> In[3]:=FileNames["subdir\\*"]
> 
> (\ needs to be escaped because \* or nearly any \<letter> combination
> has some meaning).
> 
> This is weird - first because Windows understands the forward slash as a
> directory separator, and second because it means we have to do
> search-replace orgies when trying a notebook on a different OS.  This
> would not only happen in a preamble part, but we even have some
> functions that read all data in a subdirectory, for a list of
> subdirectories.
> 
> Is there a way to write such expressions portable?  

Yes. Use of the above global directory names coupled with ToFileName is 
designed exactly for this application.

Cheers,
Paul

-- 
Paul Abbott                                      Phone: +61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    
AUSTRALIA                               http://physics.uwa.edu.au/~paul
        http://InternationalMathematicaSymposium.org/IMS2005/


  • Prev by Date: Re: Help with the User Interface in Mathematica 5.1.1
  • Next by Date: make a set of conditions without the parameters
  • Previous by thread: Re: Portable Notebooks and Filenames[]
  • Next by thread: Re: Portable Notebooks and Filenames[]