Wait command

Geoff Canyon gcanyon at gmail.com
Sun Mar 2 22:20:53 EST 2014


wait 0 ticks -- allows the screen to update
wait 0 ticks with messages -- allows the user to interact with your
interface

So:

on mouseUp
   repeat 10000
      add 1 to fld 1
   end repeat
end mouseUp

put 1 into the fld and run the above script, the script runs for a second
or so with no visual change and then the field changes to 10001. Note that
the field actually incremented by 1s, you just didn't see it because the
screen didn't update.

on mouseUp
   repeat 1000
      add 1 to fld 1
      wait 0 ticks
   end repeat
end mouseUp

run the above script and watch as the number in the field increments by 1s
for a thousand.

on mouseUp
   repeat 1000
      add 1 to fld 1
      wait 0 ticks with messages
   end repeat
end mouseUp

add a second button with:

on mouseUp
   subtract 1000 from fld 1
end mouseUp

while the first script is running the field will increment by 1s; click the
second button and the field will drop by 1000, while still incrementing.
Note that just because the wait in the first script says wait for 0 ticks
doesn't mean that's all the second script gets -- if the second script were:

on mouseUp
   repeat 1000
      subtract 1 from fld 1
      wait 0 ticks with messages
   end repeat
end mouseUp

you would see the up-counting first script be interrupted by the second,
down-counting script, for the full 1000-count, i.e. a few seconds -- and
then pick up where it left off.



On Sun, Mar 2, 2014 at 8:32 PM, <dunbarx at aol.com> wrote:

> There are very legitimate places for "wait", though more robust code can
> usually be written with "send (in time)". This has been going on for 27
> years.
>
>
> Wait is blocking. An idle handler will be locked out just like everything
> else.
>
>
>
> But a line like "wait 0 with messages does not seem to me to do much.
> Maybe retard the flow of execution a few microseconds?
>
>
> Craig
>
>
>
> -----Original Message-----
> From: Robert Sneidar <slylabs13 at me.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Sent: Sun, Mar 2, 2014 9:13 pm
> Subject: Re: Wait command
>
>
> Only reason I can think to put a wait command in a running script is to
> give a
> change for an on idle handler to be triggered. If you DO have an idle
> handler
> running somewhere and IT has a problem that causes the engine to exit to
> top,
> that might be your bugaboo.
>
> Bob
>
>
> On Mar 2, 2014, at 5:47 PM, Peter Haworth <pete at lcsql.com> wrote:
>
> > I just spent a couple of hours debugging some code and narrowed it down
> to
> > a "wait 0 with messages" command.
> >
> > WIth that command in my script, nothing after it seems to get executed.
> > When I take that command out, all works fine.
> >
> > I'm obviously misunderstanding how the wait command works.  I assumed it
> > would wait the specified amount of time, then continue executing commands
> > following it in the script.
> >
> > I have to admit, I'm not sure why the wait command is in the script in
> the
> > first place but I'd grateful for any clarification of how "wait" works.
> >
> > Thanks,
> >
> > Pete
> > lcSQL Software <http://www.lcsql.com>
> > Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> > SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription
> preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list