4590314 [rkeene@sledge /home/rkeene/projects/rivet-cgi/rivet-tcl]$ cat -n incr0.tcl
   1: ###
   2: ## incr0 ?varName? ?num?
   3: ##    Increment a variable by <num>.  If the variable doesn't exist, create
   4: ##    it instead of returning an error.
   5: ##
   6: ##    varName - Name of the variable to increment.
   7: ##    num     - Number to increment by.
   8: ###
   9: 
  10: proc incr0 {varName {num 1}} {
  11:     upvar 1 $varName var
  12:     if {![info exists var]} { set var 0 }
  13:     return [incr var $num]
  14: }
4590315 [rkeene@sledge /home/rkeene/projects/rivet-cgi/rivet-tcl]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2002-01-09 15:55:03