The event is generated when you click on the "stop" button.  It goes into an
event queue to be processed later.  Events usually get processed when your
application isn't doing anything else.  But if your application is in a
tight list processing loop, it won't check the event queue.  Conceptually,
it looks like this:

  foreach item $dataList {
      # perform lots of processing on one list item
      # check to see if the user clicked "stop"
  }

Sample code might be like this (untested):

  # create a simple gui
  grid [label .l -text "Processing"]
  grid [button .b -text "START" -command {start}]
  grid [button .b -text "STOP" -command {set stopFlag 1}]

  proc start { } {
    global stopFlag
    set stopFlag 0
    # do something that takes time
    for {set i 0} {$i<1000000} {incr i} {
        set j [expr {cos($i)}]
      if {$stopFlag} {break}
    }
  }

Bob
-- 
Bob Techentin                        [EMAIL PROTECTED] 
Mayo Foundation                                 (507) 538-5495 
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/ 


> -----Original Message-----
> From: RJ Ent. [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 20, 2001 6:32 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [vtcl-user] How to interupt a running script?
> 
> 
> Greetings,
> 
> 
> 
> At 10:25 PM 1/17/01 -0600, you wrote:
> >If you have a "STOP" button on your GUI, you will need to 
> periodically call
> >'update' during your list processing loop.  That will give 
> some time to the
> >event loop to process
> 
> 
> >" the events " 
> 
> This (the events) is the area I am unsure how to "puase" the 
> script where
> it is.  I have in mind a popup (which I can do) to stop the 
> execution or to
> continue right where it was last.  It is the pausing part I 
> am unsure how
> to tackle.:(  
> 
> Thoughts?
> 
> Many thanks!
> > and tell your application to stop.
> 
> >
> >Bob
> >-- 
> >Bob Techentin                        [EMAIL PROTECTED] 
> >Mayo Foundation                                 (507) 538-5495 
> >200 First St. SW                            FAX (507) 284-9171
> >Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/ 
> >
> >
> >> -----Original Message-----
> >> From: RJ Ent. [mailto:[EMAIL PROTECTED]]
> >> Sent: Wednesday, January 17, 2001 8:34 PM
> >> To: [EMAIL PROTECTED]
> >> Subject: [vtcl-user] How to interupt a running script?
> >> 
> >> 
> >> Greetings,
> >> 
> >> I have a tcl program that I would like to interupt during its 
> >> processing of
> >> a large list.
> >> 
> >> How does one go about doing this? 
> >> 
> >> Many Thanks!!
> >> #################################################################
> >> #RJ Ent 
> >> #http://rjent.pair.com
> >> #
> >> #  RH Linux -- http://www.redhat.com 
> >> #  FreeBSD -- http://www.freebsd.org
> >> #  VTCL -- http://sourceforge.net/projects/vtcl
> >> ################################################################
> >> 
> >> _______________________________________________
> >> vtcl-user mailing list
> >> [EMAIL PROTECTED]
> >> http://lists.sourceforge.net/lists/listinfo/vtcl-user
> >> 
> >
> >_______________________________________________
> >vtcl-user mailing list
> >[EMAIL PROTECTED]
> >http://lists.sourceforge.net/lists/listinfo/vtcl-user
> >
> >
> #################################################################
> #RJ Ent 
> #http://rjent.pair.com
> #
> #  RH Linux -- http://www.redhat.com 
> #  FreeBSD -- http://www.freebsd.org
> #  VTCL -- http://sourceforge.net/projects/vtcl
> ################################################################
> 
> _______________________________________________
> vtcl-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/vtcl-user
> 

_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/vtcl-user

Reply via email to