Page 1 of 1

Pause Function

Posted: Mon Jan 28, 2019 11:21 pm
by rbytes
The PAUSE command can be useful in some circumstances. But sometimes you want to be able to interrupt a pause. How do you do that when other commands can not be executed during a PAUSE command?

;)

Re: Pause Function

Posted: Tue Jan 29, 2019 9:25 am
by GeorgeMcGinn
Awesome. Great thinking. This will work great when I'm reading text and data produced by a program and all I have to do is touch the screen to continue the program.

I bet with a little modification I could specify the touch to be a button. This solves a problem when I write a program that produces a lot of data for some of the scientists and university professors I work with from time to time. And if I employ buttons, I may be able to allow the user to go back a screen in case they need to re-review based on the new data they just looked st.

Thank you rbytes. Great work, and it will come in handy!

rbytes wrote:
Mon Jan 28, 2019 11:21 pm
The PAUSE command can be useful in some circumstances. But sometimes you want to be able to interrupt a pause. How do you do that when other commands can not be executed during a PAUSE command?

My solution - a function that divides the desired pause length into a series of .1 sec. pauses that add up to the desired delay.
Now screen touch can be sensed every tenth of a second. If it is detected, the program will react virtually instantly to skip the remaining delay and let the program flow continue. if the screen is not touched, the delay will end after its specified length.

Code: Select all

/*
Pause function by rbytes
January 2019

A function that divides the desired pause length into a series of .1 sec.
pauses that add up to the desired delay. Now screen touch will be sensed every
tenth of a second, so if it is detected, the program will react virtually instantly
to skip the remaining delay and let the flow continue. if the screen is not touched,
the delay will end after the specified length.
*/

graphics
graphics clear 1,1,1
wait(5)
beep
end

def wait(dur)
waiter=dur*10
start:
z=z+1
get touch 0 as tx,ty
pause dur/waiter
if z>waiter then return
if tx=-1 then start
end def
I also made a wait subroutine to perform the same job. I used it in a program I posted today in Basic Programs, called "Museum of Modern Art". It holds each digital art image on screen for three seconds unless the screen is tapped. If it is, the art changes instantly. I will post the wait subroutine here tomorrow.