<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Can anyone give me some insight about the "wait for messages" command? 
The first time I ever tried to use it, I put the following lines into a
main stack script:
<p>    . . .
<br>    wait for messages
<br>    put "done waiting"
<br>    . . .
<p>I ran the script from the message box and lo and behold, nothing happened
until I moved the mouse, when "done waiting" appeared in the window. 
"Okay.  That works just as expected," I thought.
<p>The trouble is, it has never worked since!  That is, "wait for
messages" never waits, but proceeds immediately to the next line in the
script.  I've tried a number of variations (putting the wait in a
button script, calling the script in a delayed send, and so on), but with
no luck.
<p>My initial suspicion was that there are repeated messages similar to
idle, causing "wait for messages" to proceed.  I identified a small
number of potential candidates, but putting in handlers in the stack script
to signal if they were occurring showed nothing.
<p>    By the way -- this was particularly surprising for
the mouseWithin message, which seems not to follow the
<br>    usual message path.  That is, a mouseWithin
handler in a control gets the message, but without a handler in
<br>    the control, the message is not passed up the hierarchy
as you would expect.  I didn't find any documentation
<br>    of this feature.  In any event, these messages
also apparently cease when the cursor is outside any window
<br>    (unless that counts as within something else), but
"wait for messages", nevertheless, does not wait.
<p>Do I have the wrong idea about how "wait for messages" ought to work?
<p>Why should it have worked the first time, but not subsequently?
<p>Are there messages a script can never see (or that bypass the usual
message hierarchy) that, nevertheless, satisfy the wait condition of "wait
for messages"?
<p>Is there a way to see what messages are causing "wait for messages"
to stop waiting?
<p>Is there a way to get a message trace in general?  That would be
extremely useful.
<p>What does the following note in the "waitDepth" entry of the Transcript
Dictionary mean?
<p>   "The wait for messages form of the wait command allows
Revolution to respond to
<br>    messages and execute handlers while waiting."
<p>Shouldn't that be "... <i>with</i> messages form ..."?  Otherwise,
as near as I can tell, as soon as there are messages to respond to, "wait
for messages" stops waiting, so how can you "execute handlers while waiting"
when you're no longer waiting?  The only way I can reconcile this
is if Revolution always handle at least one message before resuming from
"wait for messages".  Is that how it works?  If so, how many
messages does it handle before resuming?
<p>Speaking of "waitDepth", if there are multiple waits pending, in what
order to they resume?  Last first?  Last last?  Unspecified?
<p>Does a message resume all waiting handlers, or just the next in line? 
I'm guessing all, if the documentation is correct, but the resumption order
question still pertains.
<p>I've looked in the Revolution stacks for examples of "wait for messages". 
They all look something like this:
<p>    . . .
<br>    repeat while someStatus is empty
<br>      wait for messages
<br>    end repeat
<br>    . . .
<p>Why wasn't the command "wait while someStatus is empty with messages"
used instead?  Are these equivalent?  One potential difference
I see is that the repeat loop won't pause for messages if the loop condition
is false, while "wait while" might require at least one message to proceed,
even if the condition is already false.  Is that right?
<p>Sorry for being longwinded, but a detailed section in the documentation
on execution order, in the presence of waits and sends, would be welcome,
and I'm hoping all these questions prompt some of its contents.
<br> </html>