#-------------------------------------------------------------------------- # A MAD lookalike co command for TOPSI # All arguments are optional. The current values will be used if not # specified # Dr. Mark Koennecke, November 1999 #-------------------------------------------------------------------------- proc SplitReply { text } { set l [split $text =] return [lindex $l 1] } #-------------------------------------------------------------------------- proc co { {mode NULL } { preset NULL } } { starttime [sicstime] #----- deal with mode set mode2 [string toupper $mode] set mode3 [string trim $mode2] set mc [string index $mode2 0] if { [string compare $mc T] == 0 } { counter setMode Timer } elseif { [string compare $mc M] == 0 } { counter setMode Monitor } #------ deal with preset if { [string compare $preset NULL] != 0 } { set pre $preset } else { set pre [SplitReply [counter getpreset]] } #------ count set ret [catch {counter count $pre} msg] if { $ret != 0 } { error [format "Counting ended with error: %s" $msg] } else { set cts [SplitReply [counter getcounts]] } return $cts }