Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Command to trap mutually exclusive program options

    There is a Stata programming command or function that traps a user's specifying more than one of a set of mutually exclusive, collectively exhaustive options.

    I believe that it used to be in the list of undocumented commands and functions, but I cannot find it anymore anywhere (help files & user manual entries for syntax, programming; Googling related phrases).

    Can someone point me to it?

    Typical use case would be like the following:
    Code:
    program myprogram
        syntax . . . ., [Up Down]
    
        _whatI'mlookingfor(up down)
    If a user accidentally entered
    Code:
    myprogram . . ., up down
    it would return an error to the effect that "only one of up down may be specified".


  • #2
    help opts_exclusive
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Yeah, thank you for this. Found it just a moment ago on my own. It's still "undocumented".

      Comment


      • #4
        It is one of those commands that I know exists, but somehow I always forget when I need it...
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Originally posted by Maarten Buis View Post
          It is one of those commands that I know exists, but somehow I always forget when I need it...
          Yep, that's what happened to me, too. Thanks again, Maarten. I appreciate your rapid reply very much.

          Comment


          • #6
            add example of use from collect.ado version 1.0.3
            Code:
            program ParseWarn
                syntax name(name=c_cmd) [, NOWARN WARN]
            
                opts_exclusive "`nowarn' `warn'"
                if "`nowarn'" != "" {
                    local set set collect_warn off
                }
                else if "`warn'" != "" {
                    local set set collect_warn on
                }
                c_local `c_cmd' `set'
            end

            Comment

            Working...
            X