proc setopt {opt val} {
upvar $opt var
upvar args args
set pos [lsearch -exact $args "-$opt"]
if [expr $pos >= 0] {
set pos1 [expr $pos + 1]
set var [lindex $args $pos1]
set args [lreplace $args $pos $pos1]
return
}
global globaloptions
if [info exists globaloptions] {
set pos [lsearch -exact $globaloptions "-$opt"]
if [expr $pos >= 0] {
set pos1 [expr $pos + 1]
set var [lindex $globaloptions $pos1]
return
}
}
set var $val
}