Statalist


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

st: Parsing syntax in an ado file


From   "Sergiy Radyakin" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Parsing syntax in an ado file
Date   Tue, 5 Feb 2008 22:30:45 -0500

Hello All!

I am writing an ado file and I want it to support:
1. varlist
2. using clause
3. if
4. in
5. Other parameters

I am using syntax statement to do the job.
syntax [varlist] [using/] [if] [in] [,clear] [SAVing(string)]

The program in the ado file is supposed to
A. do something with the parameters
B. do something with the file specified in using (as usual, the word
using may be omitted when varlist is empty)
C. load another file with the specified varlist, if, and in

However, since that file in C is not in the memory, (say I have no
data in the memory at all) the call to my program fails. And this is
reasonable, since no variables are in memory -- hence varlist may not
be "non-empty", etc.

I know I can parse the `0' macro myself with gettoken. But I am
looking for a more elegant solution to do it.

Q: How do I get the parts of the command named in the syntax even if
some of the parts can't be evaluated at the moment? E.g. I want
unknown_syntax_command [varlist] [using/] [if] [in] [,clear] [SAVing(string)]
to fill in the local varlist with the specified string, ignoring the
fact, that the variables with the specified  names are not present in
the dataset, that in spans the range beyond the current max, etc...

capture syntax .... either does what syntax does, or does nothing, so
is of no use.

Q2: since use is a built-in command, I can't see how the syntax is
defined there. But it is what I would want to replicate in my ado.

Any suggestions are very welcomed!

Thank you,
   Sergiy Radyakin
*
*   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