wait for messages

Bob Rasmussen brasmussen at earthlink.net
Sun Feb 24 21:02:01 EST 2002

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:

    . . .
    wait for messages
    put "done waiting"
    . . .

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.

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.

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.

    By the way -- this was particularly surprising for the mouseWithin message, which seems not to follow the
    usual message path.  That is, a mouseWithin handler in a control gets the message, but without a handler in
    the control, the message is not passed up the hierarchy as you would expect.  I didn't find any documentation
    of this feature.  In any event, these messages also apparently cease when the cursor is outside any window
    (unless that counts as within something else), but "wait for messages", nevertheless, does not wait.

Do I have the wrong idea about how "wait for messages" ought to work?

Why should it have worked the first time, but not subsequently?

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"?

Is there a way to see what messages are causing "wait for messages" to stop waiting?

Is there a way to get a message trace in general?  That would be extremely useful.

What does the following note in the "waitDepth" entry of the Transcript Dictionary mean?

   "The wait for messages form of the wait command allows Revolution to respond to
    messages and execute handlers while waiting."

Shouldn't that be "... with 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?

Speaking of "waitDepth", if there are multiple waits pending, in what order to they resume?  Last first?  Last last?  Unspecified?

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.

I've looked in the Revolution stacks for examples of "wait for messages".  They all look something like this:

    . . .
    repeat while someStatus is empty
      wait for messages
    end repeat
    . . .

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?

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20020224/af756e95/attachment.html>

More information about the Use-livecode mailing list