Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Why do `test' and a`test' make a difference?


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Why do `test' and a`test' make a difference?
Date   Sun, 10 Feb 2013 15:13:15 +0000

In Stata backslashes have two roles

1. General: As an escape character.

2. Specific, for Windows users so inclined: As a separator within pathnames.

and single left quotation marks ` also have two roles

1. As introducing local macro references.

2. As literal characters, an interpretation you insist on with \`

So

\`test'

is taken as a sign that for some reason for your own you are
protecting the ` of `test', which is why you put the \ in there.

So, don't do that. Use forward slashes for pathname separators, even
in Windows. This advice is spelled out in [U] and again in

SJ-8-3  pr0042  . . . . . . .  Stata tip 65: Beware the backstabbing backslash
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q3/08   SJ 8(3):446--447                                 (no commands)
        tip to use forward slash instead of backslash for
        directory and file names

Nick

On Sun, Feb 10, 2013 at 1:18 PM, Dirk Enzmann
<dirk.enzmann@uni-hamburg.de> wrote:
> Why does the backslash as part of the global macro $path vanish (and `test'
> is not evaluated as a local macro) when immediately combined with the local
> macro `test', although it does not vanish (and the content of `test' is
> displayed) when not immediately combined as shown in the two variants of
> -di- in the example below?
>
> * --- Stata example start: -----------
>
> global path = "d:\my folder\"
> local test = "pre_"
> di "${path}`test'my name.dta"
> di "${path}a`test'my name.dta"
>
> * --- End Stata example. ------------
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index