MathGroup Archive 2002

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

Search the Archive

Re: Getting File Directory Using Any Platform

  • To: mathgroup at
  • Subject: [mg34037] Re: [mg34013] Getting File Directory Using Any Platform
  • From: "Eric L. Strobel" <fyzycyst at>
  • Date: Sat, 27 Apr 2002 00:57:01 -0400 (EDT)
  • Reply-to: fyzycyst at
  • Sender: owner-wri-mathgroup at

on 4/26/02 3:27 AM, Ersek, Ted R at ErsekTR at wrote:

> I want a line of code that will return the directory where the Notation
> package is located and it should return a result consistent with the
> operating system used.  If the following doesn't work on your platform
> please let me know. I am also interested in any improvements to this code.
> In[1]:= 
> dirs=Which[
> $System==="Microsoft Windows","\\AddOns\\ExtraPackages\\Utilities",
> $System==="Machintosh",":AddOns:ExtraPackages:Utilities",
> True (* Unix *), "/AddOns/ExtraPackages/Utilities"
> ];
> DirectoryName[$TopDirectory<>dirs<>"Notation.m"]
> Out[1]=
> C:\Program Files\Wolfram Research\Mathematica\4.1\AddOns\ExtraPackages\


What you gave didn't work at all for me on a Mac (admittedly I only have
4.0, but still...).

Here's what I came up with:

dirs2 = Switch[$OperatingSystem,
      "MSWindows", "\\AddOns\\ExtraPackages\\Utilities",
      "MacOS", ":AddOns:ExtraPackages:Utilities",
      _, "/AddOns/ExtraPackages/Utilities"
     DirectoryName[$TopDirectory <> dirs2 <> "Notation.m"]
"Macintosh HD:myApplications:Numbers:Mathematica 4.0 \

Note several things...  'Switch' looks like the appropriate choice here.
Also, values for $OperatingSystem can include 'Unix', 'VMS', and 'MSDOS',
but I chose to use just the default of the Switch as 'Unix'.


- Eric.


Eric Strobel (fyzycyst at NOSPAM^

Design is an iterative process. The necessary number of iterations is
one more  than the number you have currently done. This is true at any
point in time.

  • Prev by Date: RE: Test of a pure function
  • Next by Date: 3D plotting
  • Previous by thread: Re: Getting File Directory Using Any Platform
  • Next by thread: Test of a pure function