Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: syntax; option real & varname

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: syntax; option real & varname
Date   Thu, 15 Aug 2002 18:48:28 +0100

Nick Winter

> capture syntax , x1(real)
> if _rc {
> 	capture syntax, x1(varname numeric)
> }
> if _rc {
> 	di as err "x1() should specify real number or numeric variable"
> 	exit 198
> }
> In short, if one -syntax- doesn't fit, the other one must.

Very spiffy solution.  One potential problem, though, is that there
could be some other problem in the syntax typed by the user, in which
case the error message would not be informative.  NOt a big problem,
probably, unless the true syntax options are a bit more complex than
example here.

>>> True. In that case,

capture syntax ... , x1(real) ...
if _rc {
	capture syntax ... , x1(varname numeric) ...

where the ... represents other stuff.

If the problem is with what was in x1() then
the user will get that message; if with
other stuff, then there will be a message
to that effect.

The only loss is a little informativeness.
Either way, the user might read the help

The more general code is often both shorter and more robust.

[email protected]

*   For searches and help try:

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