erratic screen updates (was Slow screen lock/unlock)

Jim Hurley jhurley at infostations.com
Fri Mar 18 11:29:44 EST 2005


>
>Message: 10
>Date: Fri, 18 Mar 2005 09:26:10 +0100
>From: Malte Brill <revolution at derbrill.de>
>Subject: Re: erratic screen updates (was Slow screen lock/unlock)
>To: use-revolution at lists.runrev.com
>Message-ID: <61D2C048-9787-11D9-962C-0030659A795C at derbrill.de>
>Content-Type: text/plain; charset=US-ASCII; format=flowed
>
>Hi Michael,
>
>  >I didn't see any difference between wait with messages and a simple
>wait.
>
>Using the with messages form allows other messages to pass while
>waiting. Otherwise your app. may be blocked while executing the wait.
>
>Cheers,
>
>Malte
>


Thanks Malte and Richard. I like the wait with messages idea.

I wanted to see if there was any practical differences between "wait 
with messeages" and executing the loop with a send to me routine. 
There was none in the two methods below. Each moves a graphic 
smoothly across the screen.

One surprise to me was that "wait with messages", while it allows for 
a screen refresh, it does not allow two handlers to operate 
simultaneously. To get two "balls" to move across the screen 
simultaneously, one needs to apply the "send" routine. I have learned 
this after the patient explanations of Malte and Scott.


local tLoc,tStartTime

on mouseUP
   put the ticks into tStartTime
   set the loc of grc "ball" to 10,100
   put the loc of grc "ball" into tLoc
   put 1 into i
   repeat until i > 600
     add 1 to item 1 of tLoc
     set the loc of grc "ball" to tLoc
     wait 0 with messages--allows for a screen refresh; as would "wait 
0 millisec"
     add 1 to i
   end repeat
   --doLoop 1
   put the short name of me &comma&& the ticks - tStartTime & " ticks" 
& return after field 1
end mouseUP

--Running the above handler takes 86 ticks on my system.
--Commenting out the repeat loop and inserting the doLoop command,
--I get 87 ticks. No difference to speak of.
--I should think that each method has the same practical effect.
--It appears that the "send in 0 millisec" allows for a screen 
refresh and effectively replaces
--the wait 0 with messages.

on doLoop counter
   if counter = 600 then
     put the short name of me &comma&& the ticks - tStartTime & " 
ticks" & return after field 1
     exit doLoop
   end if
   add 1 to item 1 of tLoc
   set the loc of grc "ball" to tLoc
   send "doLoop counter + 1" to me in 0 millisec--Allows for a screen refresh
end doLoop


But here was a surprise to me. Create two graphics objects, ball1 and 
ball2 with the following handlers:

Ball1 handler:

on mouseUp
   send "mouseUP" to grc "ball2"
   set the loc of me to 10,100
   put the loc of me into tLoc
   repeat 600 times
     add 1 to item 1 of tLoc
     set the loc of me to tLoc
     wait 0 with messages
   end repeat
end mouseUp

Ball2 handler:

on mouseUp
   set the loc of me to 10,140
   put the loc of me into tLoc
   repeat 600 times
     add 1 to item 1 of tLoc
     set the loc of me to tLoc
     wait 0 with messages
   end repeat
end mouseUp

When I send "mouseUP" to ball1, these handlers run successively, not 
simultaneously--synchronously and not asynchronous.

I would have thought that the "wait with messages" would allow then 
to run simultaneously. The "wait with messages" in ball1 does not 
wait for the messages in ball1. To get that behavior I have to use 
the "send to me" in at least one object.

Still learning,

Jim


More information about the Use-livecode mailing list