Look at the Tcl command vwait and see if that does what you want.
Gerry
I'm sure there is, but what does "read some variable values" mean to
you? If we can get that straight, I just know we'll be able to help you
achieve satisfaction using one of the language's facilities.
Donal.
you could use tkcon:
http://wiki.tcl.tk/tkcon
some more info:
http://wiki.tcl.tk/2?tkcon
for just following some variables
and maybe changing some of them
create a new toplevel and fill it with
labels and entries
#
set ::var1 42
# set ::var2 nix
set var3(this,element) 1234
set var3(other,element) 5678
set var3(other,item) dontshow
set watchlist {::var1 ::var2 ::var3(*,element }
set w .debug
toplevel $w
set idx 0
foreach varname $watchlist {
foreach {arrayname globpattern} [ split $varname () ] break
if {[array exist $arrayname ]} {
label $w.l$idx -text $arrayname
grid $w.l$idx -column 1 -row $idx
set ecnt 0
if { "$globpattern" == "" } {
set globpattern *
}
set elements [ array names $arrayname $globpattern ]
foreach elem $elements {
# handle similar to plain vars
label $w.l${idx}i$ecnt -text $elem
entry $w.e${idx}i$ecnt -textvariable ${varname}($elem)
grid $w.l${idx}i$ecnt -column 2 -row $idx
grid $w.e${idx}i$ecnt -column 3 -row $idx
incr ecnt
incr idx
}
} else {
label $w.l$idx -text $varname
entry $w.e$idx -textvariable $varname
grid $w.l$idx -column 1 -row $idx
grid $w.e$idx -column 3 -row $idx
}
incr idx
}
voila, a window into your app
G!
uwe
entry $w.e${idx}i$ecnt -textvariable ${arrayname}($elem)
You probably want a debugger. http://wiki.tcl.tk/4003 gives some
pointers. To satisfy your exact request, it's pretty easy to hand-roll
some of these tools yourself. For instance, here is a proc that will
"pause" execution when called and present an interactive prompt (just
like at the tclsh prompt) at that point in your program. You can then
use normal Tcl commands to examine the state of the program. Use
"continue" to then resume execution, or "break" to abort.
proc debug-prompt {} {
set cmd ""
set level [expr {[info level]-1}]
set prompt "DEBUG\[$level\]% "
while 1 {
puts -nonewline $prompt
flush stdout
gets stdin line
append cmd $line\n
if {[info complete $cmd]} {
set code [catch {uplevel #$level $cmd} result]
if {$code == 0 && [string length $result]} {
puts stdout $result
} elseif {$code == 3} {
# break
error "aborted debugger"
} elseif {$code == 4} {
# continue
return
} else {
puts stderr $result
}
set prompt "DEBUG\[$level\]% "
set cmd ""
} else {
set prompt " "
}
}
}
And an example session:
% proc foo {args} {
set a 1
debug-prompt
puts "Resumed, a = $a, args = $args"
}
% proc bar val {
foo $val
}
% bar 12
DEBUG[2]% info locals
args a
DEBUG[2]% info level 0
foo 12
DEBUG[2]% set a
1
DEBUG[2]% set a "4 8 15 16 23 42"
4 8 15 16 23 42
DEBUG[2]% continue
Resumed, a = 4 8 15 16 23 42, args = 12
Hopefully that is self-explanatory. You can use "uplevel 1 debug-prompt"
to move up the callstack, and "continue" to move back down. With a
little alteration you can make this code present a debug shell over a
network socket or any other channel. Tkcon builds in this kind of
functionality (and more), as do other debugging tools available, but as
you can see, Tcl makes this kind of thing easy to begin with.
-- Neil
Are you asking for something as simple such as gets?
In tcl,
gets stdin var
puts "Variable is $var"
Regards
Paul
I don't want her thinking, "Why, I asked for something that
every other language builds in automatically, and these jokers
tell me that Tcl requires pages of code to achieve the same",
when the apparent mismatch results merely from confusion between
different vernaculars (Fortran vs. Tcl, for example).
> It's possible that Maura wants something that fits in one line
> of code, or a few words of explanation. All the follow-ups have
> been valuable and accurate, but we're still fumbling to achieve
> a common vocabulary.
may the dialogs begin! <deep boing>
uwe
did this just loose moentum or was it continued under the rose?
uwe