Posted to tcl by patthoyts at Sat Dec 09 19:18:56 GMT 2006view raw
- proc InitNickState {nick level somethingelse} {
- variable uid
- set State [namespace current]::nick[incr uid]
- upvar #0 $State state
- set state(nick) $nick
- set state(level) $level
- set state(somethingelse) $somethingelse
- return $State
- }
- Then to use it:
- proc CheckLevel {nick} {
- foreach State [info vars [namespace current]::nick*] {
- if {[set [set $State](nick)] eq $nick} {
- return [set [set $State](level)]
- }
- return -code error "nick not found"
- }
- or if you keep the State array id you can use
- proc Level {State) {
- upvar #0 $State state
- return $state(nick)
- }