can't read "argv0": no such variable
    while executing
"open $argv0"
    (in namespace eval "::request" script line 3)
    invoked from within
"namespace eval ::request $script"
    ("::try" body line 12)

OUTPUT BUFFER:

#!/usr/local/bin/wish set fd [open $argv0] set txt [read $fd] close $fd if {$argc == 0} { set n 5 } else { set n [lindex $argv 0] } set data "[string repeat $txt $n]" for {set i 0} {$i < [string length $data]} {incr i 20} { lappend offsets $i [expr $i + 10] } proc markdata {str off} { set prev 0 set ldata [list] foreach {s e} $off { if {$prev < $s} { lappend ldata [string range $str $prev [expr $s -1]] {} } lappend ldata [string range $str $s [expr $e - 1]] TEST set prev $e } return $ldata } set data2 [markdata $data $offsets] # data exists - just add tags proc p1 {txt off} { $txt tag remove TEST 1.0 end set cmd [list $txt tag add TEST] foreach {s e} $off { lappend cmd [$txt index "1.0 + $s c"] [$txt index "1.0 + $e c"] } eval $cmd update } # delete & re-add text proc p2 {txt off} { set str [$txt get 1.0 end] $txt delete 1.0 end set args [markdata $str $off] eval $txt insert end $args update } # have text in memory proc p3 {txt str off} { $txt delete 1.0 end set args [markdata $str $off] eval $txt insert end $args update puts ">>$args<<" } # can have data pre-built proc p4 {txt data} { $txt delete 1.0 end eval $txt insert end $data update } proc timers {} { global ITER offsets data data2 puts "Timing with $ITER iterations ([string length $data] characters and [expr {[llength $offsets]/2}] tagged regions)" puts -nonewline " Proc p1 : " puts [format "%8.6f seconds" [expr [lindex [time { p1 .t $offsets} $ITER] 0] / 1000000.0]] puts -nonewline " Proc p2 : " puts [format "%8.6f seconds" [expr [lindex [time { p2 .t $offsets} $ITER] 0] / 1000000.0]] puts -nonewline " Proc p3 : " puts [format "%8.6f seconds" [expr [lindex [time { p3 .t $data $offsets} $ITER] 0] / 1000000.0]] puts -nonewline " Proc p4 : " puts [format "%8.6f seconds" [expr [lindex [time { p4 .t $data2} $ITER] 0] / 1000000.0]] puts "Testing Complete\n" } text .t -yscrollcommand ".s set" scrollbar .s -command ".t yview" frame .f1 button .f1.p1 -text "p1" -command [list p1 .t $offsets] button .f1.p2 -text "p2" -command [list p2 .t $offsets] button .f1.p3 -text "p3" -command [list p3 .t $data $offsets] button .f1.p4 -text "p4" -command [list p4 .t $data2] frame .f2 entry .f2.e -textvar ITER set ITER 10 button .f2.b -text "Run Timing" -command timers pack .f2 .f1 -side bottom -fill x pack .s -side right -fill y pack .t -expand 1 -fill both pack .f1.p1 .f1.p2 .f1.p3 .f1.p4 -side left -expand 1 -fill none pack .f2.e .f2.b -side left -expand 1 -fill none .t insert end $data .t tag config TEST -background red update timers exit