Statalist


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

Re: ***SPAM*** st: AW: parsing problem


From   Federico Belotti <[email protected]>
To   [email protected]
Subject   Re: ***SPAM*** st: AW: parsing problem
Date   Thu, 07 Jan 2010 16:05:29 +0100

Tks Martin for your reply. My problem persists when I specify the option's argument with a blank. Try the following

capt prog drop myprog
prog def myprog
   vers 10.1
   syntax, OPTION(string asis)
local option: subinstr local option "," " ", all
   di `"`option'"'
local new_option: list clean option
   di `"`new_option'"'
end

myprog, option(1 "example", 2 "example 1")


--
Federico Belotti
Faculty of Economics
Department of Financial and Quantitative Economics
Tor Vergata University
tel: +39 06 7259 5624/25
e-mail: [email protected]



Martin Weiss wrote:
<>
I get the correct answer with this:


*************

capt prog drop myprog

prog def myprog vers 10.1
	syntax, OPTION(string asis)
	di `"`option'"'
	local new_option: list clean option
	di "`new_option'"
end

myprog, option(1 "example")
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Federico
Belotti
Gesendet: Donnerstag, 7. Januar 2010 14:36
An: StataList
Betreff: st: parsing problem

*Dear all,

I've the following parsing problem in writing one of my ado's:

I need that option's argument be returned just as the user typed them, with quotes and with leading and trailing blanks. So, I use:

*
prog define example
syntax, OPTION(string asis)


*and when I type:*


example, option(1 "example")


*I get what expected, that is:*

di `"`option' " '
1 "example"


*Then I perform some tasks. At some point of the code I need to strip off double quotes from the local option. I tried without success with:*

1) local new_option: subinstr local option """ "", all
2) local new_option =  regexr(`"`option' " ', """, "")
3) local new_option: list clean option


*Can someone help me?

thx

Federico
*

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