send ___ to me in ___ sec

Dar Scott dsc at swcp.com
Tue Apr 23 16:55:00 EDT 2002


On Tuesday, April 23, 2002, at 02:51 PM, Ivers, Doug E wrote:

> Isn't there a way to "send ___ to me when all currently running 
> scripts are done"?  Or, "send ___ to me on first idle message"?
>
> I want something to happen after all other scripts in the queue 
> have competed... surely this is a common need.

If what you want is to insert a script right after all those in the 
send queue, then try this:  Look at pending messages, find the 
message with the latest time (item 2) and then send right after 
that one.  If the list is empty send ... in 0.

(However if you have a message in the queue to remind you of 
something in 5 minutes, do you really want to queue a send behind 
that?)

However, not all queued messages show up there.  I know mouseUp as 
generated by a mouse click is not.  It may turn out that all 
Revolution generated messages are not.  I have gotten the 
impression that mouseUp and the like are called after ready 
messages in the send queue (pending messages).  Some Revolution 
messages are probably called directly from a command and not 
queued.  I would think deleteCard might be like that.

> For example, I need to do some clean up after a card is deleted.  
> The deletedCard message is sent before the delete, so I'm using 
> this:
>
>  on deleteCard
>     send updateList to field "myList" in 0.1 sec
> end deleteCard

I don't understand why or how this works.  How does the field exist 
after the card is gone?  Does this go to a field of the same name 
on the next card?

> This works on my machine, but may not work on all machines in all 
> situations.  Is there a more elegant way?  How can I put the send 
> command at the end of the currently runningscripts?
>
I'm not sure what you mean by currently running.  I think unless 
you use wait with messages, only one handler--with handlers called 
by it (message handlers and functions) forming a "call stack"--is 
running.  Immediate execution is only in the deepest call.  I don't 
think of queued sends as running.  Or other queued messages.

If all you are doing is deleting the card in a script and want to 
run a script after all called handlers have finished (returned) and 
then the top handler (say a mouseUp) has finished, then all you 
need is send... in 0.

I'm still learning on this, myself.

Dar Scott




More information about the use-livecode mailing list