Hi Nicolas,

If you want a process to be user-interruptable, you have to program it
so that it executes in "chunks", so MC can receive new user-generated
events at the end of each chunk. Otherwise, MC will wait until the whole
handler has executed before checking the event queue.

The easiest way I know of to make this happen is by using the "send"
command. For example, consider this re-do of your script as the script
of a single button:

----------------------------
local x -- persistent data available to all handlers in script



on mouseUp
  
  -- change the button label with each click
  if the label of me = "stop" then
    hide group "bin-bon!"
    cancel item 1 of the pendingMessages
    set the label of me to "go"
  else
    put zero into x
    set the label of me to "stop"
  end if
  
  -- start the "doBinBon" process
  send "doBinBon" to me
  
end mouseUp



on doBinBon
  
  -- bail out after the right number of executions
  add 1 to x
  if x > 4 then
    hide group "bin-bon!"
    set the label of me to "go"
    exit doBinBon
  end if
  
  -- show or hide the group and put another
  -- "doBinBon" message in the queue
  get the visible of group "bin-bon!"
  if it = false then
    show group "bin-bon!"
    send "doBinBon" to me in 400 milliseconds
  else
    hide group "bin-bon!"
    send "doBinBon" to me in 600 milliseconds
  end if
  
end doBinBon
----------------------------

You could say that "send" submits a handler for background processing,
while a user-generated "mouseUp" event starts a foreground process that
has priority over any messages in the background "pendingMessages"
queue. The "mouseUp" handler will be executed as soon as the
currently-processing "doBinBon" message is completed.

HTH.
Phil Davis



Nicolas R Cueto wrote:
> 
> Hello again,
> 
> For impatient users of my stacks, I'd like to rescript this
> mouseDown-initiated repeat loop so that it can be escaped (via the
> return key?) without leaving group "bin-bon!" hidden:
> 
> repeat with i = 1 to 2
>       show group "bin-bon!"
>       wait 400 milliseconds
>       hide group "bin-bon!"
>       wait 600 milliseconds
>       show group "bin-bon!"
> end repeat
> 
> BTW, I want to thank a thousand times over whoever initiated-and
> answered-that recent thread about transferring stacks from PCs to Macs:
> ages and ages of diddling with mc-engine or compatible mac/pc file
> settings, when all it needed was a simple "open stack x" typed into
> Message Box. Ditto on the what-an-idiot-I-am thought. Perhaps this
> simple little line should be appended to MC's reference stack?
> 
> Which now reminds me: anyone know what Japanese fonts are most common to
> Macs?
> 
> Happier than ever with MC!
> 
> --
> Nicolas R Cueto
> Takakura JHS/SHS
> Nagoya, Japan

-- 
Phil Davis
------------------
[EMAIL PROTECTED]

Reply via email to