Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please explain BLT code

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hi!

I managed to make the following out of an example of the blt demos:

#!bin/sh
#exec wish ${1+"$@"}

package require BWidget
package require BLT

if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}


set command [list tar -tvf tutu.tar]

proc InsertText { string tag } {
.text insert end "$tag: " "" $string $tag
update idletasks
}

proc DisplayOutput { name1 name2 how } {
upvar #0 $name1 arr

InsertText "$arr($name2)\n" stdout
set arr($name2) {}
}

proc DisplayErrors { name1 name2 how } {
upvar #0 $name1 arr

InsertText "$arr($name2)\n" stderr
set arr($name2) {}
}

trace variable results(stdout) w DisplayOutput
trace variable results(stderr) w DisplayErrors

# Create widgets
text .text
.text tag configure stdout -font -*-Helvetica-Bold-R-*-*-18-*-*-*-*-*-*-* -foreground green2
.text tag configure stderr -font -*-Helvetica-Medium-O-*-*-18-*-*-*-*-*-*-* -foreground red2

pack .text -fill both

.text delete 1.0 end
set results(status) {}
eval "bgexec results(status) -lasterror results(stderr) -lastoutput results(stdout) $command &"


I understand most of it except for

"trace variable results(stdout) w DisplayOutput"

DisplayOutput has three parameters:

"proc DisplayOutput { name1 name2 how }"

what does this do?
"upvar #0 $name1 arr"

and in
"InsertText "$arr($name2)\n" stdout
set arr($name2) {}"

how are name1, name2 and how been updated?

Thanks!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top