Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: user input as scalar value


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: user input as scalar value
Date   Thu, 26 Jun 2008 17:52:21 +0100

Hi,


Thanks all for your suggestions..

And thanks very much Joseph for that clarification. But,  Does that depend
anyway on whether you use _request(foo) or _request(_ foo)

See below, 

1. with _request(foo)

. display in smcl as input "Enter value for foo: " _request(foo) 
Enter value for foo: . n

. display in smcl as text "local " as result "`foo'"
local 

. display in smcl as text "global " as result "$foo"
global n

. 
end of do-file

2. with _request(_foo)

. do "C:\DOCUME~1\corpfin\LOCALS~1\Temp\STD00000000.tmp"

. display in smcl as input "Enter value for foo: " _request(_foo) 
Enter value for foo: . m

. display in smcl as text "local " as result "`foo'"
local m

. display in smcl as text "global " as result "$foo"
global n


thanks very much
rajesh

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 26 June 2008 17:05
To: [email protected]
Subject: RE: st: RE: user input as scalar value

A major correction! Thanks, Nick 

Joseph Coveney
Sent: 26 June 2008 15:49
To: Statalist
Subject: Re: st: RE: user input as scalar value

Nick Cox wrote:

Yes, you can do this.

A canonical exchange within the do file is

di "Enter value for foo: " _request(foo)

after which local foo contains the value typed.

------------------------------------------------------------------------
--------

Just a technical clarification:  it's returned in a global macro and not
a
local macro.  (I *have* happened to have used it on rare occasion, and
have
got stung nearly each time for forgetting this.)

Joseph Coveney

. display in smcl as input "Enter value for foo: " _request(foo)
Enter value for foo: . Bar

. display in smcl as text "local " as result "`foo'"
local

. display in smcl as text "global " as result "$foo"
global Bar

. exit

end of do-file

*
*   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/

*
*   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/



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