wait with messages

Dar Scott dsc at swcp.com
Wed Aug 11 12:23:10 EDT 2004


On Aug 10, 2004, at 2:06 PM, K wrote:

> I seems that when I execute a wait with messages for a specific 
> contition and another event execute a wait with messages on a 
> different condition the seconds wait cancels the first.

In other mail:

> Task aka event '1' is executing code but needs to wait for a variable 
> to be altered by a "send in time" task '2'.  Task '2' also realizes it 
> must wait on task '3' to alter a variable so it execute the wait with 
> messages also.  When task '2' executes this task '1' suddenly aborts 
> or returns from it's wait (even though '2' has not made any 
> modification to the variable.

This seems to work for me in Rev 2.2 on OS X 10.3.4.

I made this card script:
****************************************************************
local a
local b

on setA
   put true into a
   log "a is set"
end setA

on setB
   put true into b
   log "b is set"
end setB

on test
   put empty
   put false into a
   put false into b
   log "variables are cleared"
   log "before wait for a"
   wait until a with messages
   log "after wait for a"
   log "all done"
end test

on insideTest
   log "before wait for b"
   wait until b with messages
   log "after wait for b"
end insideTest

on log logText
   put the long time && quote & logText & quote after message
   put " a = " & a after message
   put "; b = " & b & lf after message
end log
*****************************************************************

I put on the card 4 buttons, one for each of commands setA, setB, test, 
and insideTest.  I labeled them such and had the mouseUp call the 
corresponding one.

On these button clicks in this order:  test, insideTest, setA, setB

...I get this result:

10:11:24 AM "variables are cleared" a = false; b = false
10:11:24 AM "before wait for a" a = false; b = false
10:11:25 AM "before wait for b" a = false; b = false
10:11:27 AM "a is set" a = true; b = false
10:11:29 AM "b is set" a = true; b = true
10:11:29 AM "after wait for b" a = true; b = true
10:11:29 AM "after wait for a" a = true; b = true
10:11:29 AM "all done" a = true; b = true

That looks right to me.  I tried some variations and those look right.  
Note that because of the nesting, the wait for a is blocked by the wait 
for b.  Looking at the time, you can see that once the setB button is 
clicked, everything wraps up.

Dar Scott




More information about the use-livecode mailing list