Re: Getting File Directory Using Any Platform

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

on 4/26/02 3:27 AM, Ersek, Ted R at ErsekTR at navair.navy.mil 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\ > Ted, 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: In[26]:= dirs2 = Switch[$OperatingSystem, "MSWindows", "\\AddOns\\ExtraPackages\\Utilities", "MacOS", ":AddOns:ExtraPackages:Utilities", _, "/AddOns/ExtraPackages/Utilities" ]; DirectoryName[$TopDirectory <> dirs2 <> "Notation.m"] Out[27]= "Macintosh HD:myApplications:Numbers:Mathematica 4.0 \ Files:AddOns:ExtraPackages:" 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'. HTH, - Eric. -- Eric Strobel (fyzycyst at NOSPAM^mailaps.org) ===================================================================== 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. =====================================================================