Timing
Sarah Reichelt
sarah.reichelt at gmail.com
Mon Jan 2 21:50:42 EST 2006
> I've been trying to get a simple timing script
> going and so far haven't managed. Basically
> I need a routine that shows an image after a
> certain number of seconds. I've tried Ticks
> and seconds but neither seemed to do it.
>
> What I need is something like
>
> put the ticks into elapsedTicks
> repeat while elapsedTicks < 240 -- 240 being four seconds
> set the visible of image "TheTitle" to false
> end repeat
> set the visible of image "TheTitle" to true
>
> In my tests it drops through the while loop immediately
> and sets the image to visible, rather than waiting the
> desired four seconds.
In your script, you don't update elapsedTicks within your repeat loop,
so it will never change. I would have thought this would give you an
infinite loop, so I can't see why it drops through.
However, you would be better using "send in time" instead of making
your program stop completely during the delay. Try something like
this:
on hideImage
set the visible of image "TheTitle" to false
send "showImage" to me in 4 seconds
end hideImage
on showImage
set the visible of image "TheTitle" to true
end showImage
This allows other stuff to happen during the 4 seconds e.g. moving the
window, choosing menus, clicking other buttons.
HTH,
Sarah
More information about the use-livecode
mailing list