Version 0 of text mode (terminal) progress bar / progressbar

Updated 2006-09-29 03:42:00

Wrote this one because I didn't find this one: Progress. In some ways mine is simpler and prettier (although less readable). In case someone finds it useful - here it is, up for the taking (or improving)...

 proc progres {cur tot} {
   if {$cur % ($tot/300)} { return }
   set total 76
   set half [expr {$total/2}]
   set percent [expr {100.*$cur/$tot}]
   set val (\ [format "%6.2f%%" $percent]\ )
   set str "\r|[string repeat = [expr {round($percent*$total/100)}]][string repeat { } [expr {$total-round($percent*$total/100)}]]|"
   set str "[string range $str 0 $half]$val[string range $str [expr {$half+[string length $val]-1}] end]"
   puts -nonewline stderr $str
 }