Picking up on Nick's comment, the dirsep is shorthand for directory
separator, so it will return a valid directory separator depending on the
operating system.
you might be able to attack you problem by code like this:
early in you do file, define the drive:
local drive=cond("$S_OS"=="Windows","C:",":C")
..then later code:
use `drive'`c(dirsep)'stata`c(dirsep)'auto, clear
This should work on both mac and windows...
Michael Blasnik
[email protected]
----- Original Message -----
From: "Danielle H. Ferry" <[email protected]>
To: "StataList" <[email protected]>
Sent: Monday, September 22, 2003 4:06 PM
Subject: Re: st: RE: Cross-platform mobility
> On 9/22/03 3:56 PM, "Nick Cox" <[email protected]> wrote:
>
> > Danielle H. Ferry
> >>
> >> Not sure if there is a solution to this, but I figured I'd
> >> throw it out
> >> there. I have an external hard drive which I use on both a
> >> Mac (OS X) and a
> >> PC (Win XP). I write all my Stata work to this HD. I
> >> sometimes call datasets
> >> or do-files from directories other than the one in which I
> >> am working. In
> >> this case, it is necessary to list the full pathname. The
> >> problem is that
> >> the pathname is specified with ":" as separators (i.e.,
> >> :hd:bigdirectory:smallerdirectory:filename.do) on a Mac but
> >> with "\" on a PC
> >> (i.e., C:\bigdirectory\smallerdirectory\filename.do).
> >> Notice also, that a
> >> Mac indicates the hard drive name by putting a ":" in front
> >> of the pathname
> >> and a PC specifies the hard drive name by putting a ":\"
> >> after the hard
> >> drive name. Much thanks for any ideas!
> >
> > I am not clear quite how this is biting you,
> > but Stata provides a dirsep which depends on
> > your platform.
> >
> > In Stata 7, this is accessed by `: dirsep'
> > and in Stata 8 by `c(dirsep)'.
> >
> > Nick
> > [email protected]
>
> I don't understand what you are referring to. The problem I have is that
> suppose I write a do-file that has one line that looks like this:
>
> use :C:stata:auto, clear
>
> This will work fine when I run on my Mac. If I try to run on a PC,
however,
> I will have to change the line to:
>
> use C:\stata\auto, clear
>
> Each time I go back and forth between the Mac & PC, I will have to change
> the way the pathname is specified.
>
> -Danielle
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/