Pause Function

Post Reply
User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Pause Function

Post 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?

;)
Last edited by rbytes on Tue Jun 18, 2019 6:13 am, edited 1 time in total.
The only thing that gets me down is gravity...

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: Pause Function

Post 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.
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

Post Reply