Dear All,
the following reference describes the use of repeated options in Stata:
https://www.stata.com/manuals/g-4con...tedoptions.pdf
I do not find, though, a description of declaring commands that support repeated options.
I'd like to declare a command that would support syntax such as
mycmd , optname(x y "some text label) optname(z t "some other label") optname(u v "yet another text label) opt1() opt2() .....
I believe repeated options are standard for graphing commands, where I can find an example of e.g. merging multiple by() options into a single by() option (see graph.ado). But I was wondering if there is a more straightforward declaration of it. I recall there were procedures to collect repeated options together either appending to each other, or replacing the previous value with the current for each option, but don't seem to find them now.
Ideally, I'd like the syntax to be something like: syntax , optname(string repeated)
then `optname' should evaluate to `"`"x y "some text label""' `"z t "some other label""' `"u v "yet another text label""'"'
with which I can later do word 1, word 2, etc. to obtain individual triplets.
A head on approach results in an error:
Any advice is welcomed.
Thank you, Sergiy
the following reference describes the use of repeated options in Stata:
https://www.stata.com/manuals/g-4con...tedoptions.pdf
I do not find, though, a description of declaring commands that support repeated options.
I'd like to declare a command that would support syntax such as
mycmd , optname(x y "some text label) optname(z t "some other label") optname(u v "yet another text label) opt1() opt2() .....
I believe repeated options are standard for graphing commands, where I can find an example of e.g. merging multiple by() options into a single by() option (see graph.ado). But I was wondering if there is a more straightforward declaration of it. I recall there were procedures to collect repeated options together either appending to each other, or replacing the previous value with the current for each option, but don't seem to find them now.
Ideally, I'd like the syntax to be something like: syntax , optname(string repeated)
then `optname' should evaluate to `"`"x y "some text label""' `"z t "some other label""' `"u v "yet another text label""'"'
with which I can later do word 1, word 2, etc. to obtain individual triplets.
A head on approach results in an error:
Code:
program define foobar version 16.0 syntax , myoption(string) display `"`myoption'"' end . foobar, myoption("1") myoption("2") option myoption() not allowed
Any advice is welcomed.
Thank you, Sergiy
Comment