Program Instruction executions? - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Program Instruction executions? - Solved

Post by DR White » Mon Oct 19, 2015 12:03 pm

I am working an an animation and sometimes I get some random results that appear to be related to when I move the mouse or maybe a "Send to me" instruction and I need to know how these handlers work.

I know the priority of the messages (more or less - object to card to stack).

My program uses " send to me" and card "Mouse down", "mouseV" and "mouseH" (to simulate a swipe left,right,up or down).

My question is how does LiveCode 7 and 8 respond when it is inside a stack routine the following events occur:

1. When it comes time for the "Send to me" message to return.
a. Does it wait for the program to finish the current routine. before going to the routine with the "send to me" instruction.
b. Does it immediately exit the routine and go to the routine that has the "send to me" and after completing the "send to me" routine does not come back to point it was in the previous routine
c. Does it immediately exit the routine and go to the routine that has the "send to me" and after completing the "send to me" routine returns to the same point it was just before it exit the routine.

2. When the "card" Mouse is clicked or moved and it leaves the current routine that is running, what happens?
a. Does it wait for the program to finish the current routine
b. Does it immediately exit the current routine and go to the "card MouseDown" routine and after completing the card routine not come back to the previous routine
c. Does it immediately exit the current routine and go to the "card MouseDown" routine and after completing the card routine back to the previous routine to the same point it was just before it exit the routine.

Thanks,

David
Last edited by DR White on Sun Nov 29, 2015 4:48 pm, edited 1 time in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Program Instruction executions?

Post by jacque » Mon Oct 19, 2015 8:35 pm

DR White wrote:1. When it comes time for the "Send to me" message to return.
a. Does it wait for the program to finish the current routine. before going to the routine with the "send to me" instruction.
b. Does it immediately exit the routine and go to the routine that has the "send to me" and after completing the "send to me" routine does not come back to point it was in the previous routine
c. Does it immediately exit the routine and go to the routine that has the "send to me" and after completing the "send to me" routine returns to the same point it was just before it exit the routine.
It depends on how the "send" command is structured. If there is a time parameter ("send x to me in 1 second") then the current handler completes and the sent command executes after the allotted time. If you send in 0 seconds, the command will execute immediately after the originating handler finishes.

However, there is no reason to use "send" if the second handler is already in the same script, just call the handler directly. In that case it acts the same as "send" without a time parameter; the called handler executes in-line then the rest of the original handler completes. In other words, these are identical:

Code: Select all

on doSomething
  send "handler2" to me
end doSomething

on doSomething
  handler2
end doSomething
The "send" command has overhead and is expensive in engine terms, so it is preferable to avoid it when possible.
2. When the "card" Mouse is clicked or moved and it leaves the current routine that is running, what happens?
a. Does it wait for the program to finish the current routine
b. Does it immediately exit the current routine and go to the "card MouseDown" routine and after completing the card routine not come back to the previous routine
c. Does it immediately exit the current routine and go to the "card MouseDown" routine and after completing the card routine back to the previous routine to the same point it was just before it exit the routine.
The first option "a". The current handler always completes, other actions are placed in a queue and messages are sent from the queue in the order they occurred.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Program Instruction executions?

Post by DR White » Mon Oct 19, 2015 9:47 pm

Jacque,

Thanks

Post Reply