Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

global on single var broken; use array if you want globals (my interp perhaps)

38 views
Skip to first unread message

Conor Williams

unread,
Oct 11, 2021, 8:05:23 PM10/11/21
to
array set timerArr { eeit 0 timeVar 73 stop 0}
frame .frame1; pack .frame1 -side left; frame .frame2; pack .frame2 -side right;
button .frame1.display -width 8; pack .frame1.display
button .frame1.bzeroms -command "zeroms" -text "zeroms"; pack .frame1.bzeroms
button .frame2.pause -command "pause" -text "pause"; pack .frame2.pause
button .frame2.quit -command "eeit" -text "quit" ; pack .frame2.quit;
set blah [expr 1+0+7]
proc zeroms {} {global timerArr; set timerArr(timeVar) 4;}
proc eeit {} {global timerArr; set timerArr(eeit) 1;}
proc pause {} { global timerArr; if {$timerArr(stop) == 0} {
set timerArr(stop) 1;} elseif {$timerArr(stop) == 1} {set timerArr(stop) 0}}
while {1 == 1} {
if {$timerArr(stop) == 0} {
set a $timerArr(timeVar); incr a; .frame1.display configure -text $a;
set timerArr(timeVar) $a;}
set timerArr(timeVar) $timerArr(timeVar); after 998; update;
if {$timerArr(eeit) == 1} {set timerArr(eeit) 1; exit 0;}
}
#on dual core 1550 1d /c:en#eof

Gerald Lester

unread,
Oct 12, 2021, 8:33:25 AM10/12/21
to
Dude,

Tell us what you are seeing.
Tell us what you are expecting.

And tell us why in the world you have a "while true" -- that should be
done in your C code.

Suggestion: you may want to invert your process and make your C an
extension that a Tcl script calls instead of the C "driving" the Tcl/Tk.

--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+

Conor Williams

unread,
Oct 14, 2021, 3:04:33 PM10/14/21
to
Gerald - you do realise that tclsh is multi-threaded? /c:20211410

Conor Williams

unread,
Oct 14, 2021, 3:11:12 PM10/14/21
to
and also wi-sh (... is multiThreaded...) do you know what that doth mean Gerald
Lester? /c:202114102000063.9m
0 new messages