Posted to tcl by kostix at Thu Aug 30 22:16:32 GMT 2007view pretty

proc FrobnicateFoo args {
  set dircmd  ""
  set filecmd ""

  foreach {opt val} {
    switch -- $opt {
      -dircmd -
      -dircommand {
        set dircmd $val
      }
      -filecmd -
      -filecommand {
        set filecmd $val
       }
       default {
         return -code error "bad option \"$opt\":
           must be one of -dircommand or -filecommand"
       }
    }
  }

  ...
}