Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: two questions about the shell command behavior -- Windows XP


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: two questions about the shell command behavior -- Windows XP
Date   Mon, 8 Dec 2008 22:06:37 -0000

I've got only partial comments. I don't understand your #1. 

1. The shell never sees local macros, only their contents
=========================================================

You have got to think in terms of what you type and what the shell sees
as related, but quite distinct. 

In particular, the shell knows nothing about local macros. It only sees
what the interpreter (for so we'll dub the part of Stata that takes what
you type and tries to make sense of it) passes along. 

So, when you write about passing along local macros, that is at best
shorthand for the results: i.e. it is as if the local macros are passed
because the shell gets to see their contents. 

My guess is that your understanding is better than your writing, but I
have only your writing to judge. 

2. Windows doesn't know about Stata's flexibility -- or otherwise
=================================================================

I think you're right. Windows knows nothing about Stata's willingness to
indulge \ and / alike -- or about Stata's insistence on " " to
disambiguate filepaths with spaces. 

Nick 
[email protected] 

Gabi Huiber

I need to make room on a disk and I thought I'd do this on an ongoing
basis from within a larger Stata process that runs every day. So I
need to move files around. I thought that this prototype would get me
started:

clear
set more off

local root      "c:/work/my root directory/"
local to_path   "to_here\"
local from_path "from_here\"
local move_this "example_list.txt"

cd "`root'"

!move `from_path'`move_this' `to_path'`move_this'
dir "`to_path'"
dir "`from_path'"

!move `from_path'example_list.txt `to_path'example_list.txt
dir "`to_path'"
dir "`from_path'"

I have two questions about the shell command:

1. The shell modifier (shell or !) seems to pass along the local
macros with the immediate folder names -- `from_path' and `to_path' --
but it does not do the same with the local macro that holds the file
name. It would be nice if it did, because local macros that hold file
names would make it a lot easier to loop across multiple file name
variants. Does anybody know what explains this selective treatment of
local macros?

2. The shell modifier does not allow me to enclose file path or file
name macros in quotes in order to accommodate spaces. In this case I
cd'd into the `root' path and the very last folders of interest had no
spaces, but I won't always be so lucky. Does anybody know of a
workaround?

3. This is more an idle puzzle than a real issue, though it might grow
into one. When I started using forward slashes in Stata, I thought I
could do so because Windows didn't care either way. But it does. The
XP command prompt does not recognize forward slashes. So it's very
nice of Stata to make that problem go away, especially if you have
folder names whose first character, when paired with a backslash,
could be mistaken for a special character. I guess, though, that Stata
can only go so far in offering this convenience. You have to
relinquish it when you invoke the shell, it seems. Too bad, but not
critical.

But issues (1) and (2) are nuisances, and they are strange. Inside
Stata you can string along as many macros as you want, so (1) should
not be an problem; and you can use quotes to declare file paths with
spaces in them both inside Stata and at the Windows command prompt, so
(2) shouldn't be one either.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index