REM See the WYWTK Index of BBC BASIC Tutorials for more help with BBC BASIC. Many pages give you more than just the code, the way this one does.
REM wywtk.com/prgm/bas/basb-med-tim-2.htm
REM MedTime2.BBC- Meditation Timer
REM VERS 07 Apr 2025-13:50
REM Characters accumulating in the KEYBOARD BUFFER made my
REM life difficult for a while. "Press and HOLD" keys is
REM NOT the way to go!
PRINT "Hi. Repeat..."
PRINT "Don't press more than one key at any time."
PRINT "To start, press a key BRIEFLY. (Not 'Q')"
PRINT "Then BRIEFLY press a key (Again, not 'Q')"
PRINT "Do this at least 9 times to see all that the program does."
PRINT "Until you've had enough!"
PRINT "(Q TO Quit)"
REPEAT
PRINT "But first set the WAIT time. (20 is probably"
PRINT "about right. More than 5.)"
INPUT delay%
UNTIL delay%>5
PRINT
ci$="i"
co$="*"
ch$="."
REM Flush buffer
REPEAT
pressed$=INKEY$(2)
UNTIL pressed$=""
REPEAT : REM Wait for user to press key...
pressed$=INKEY$(2)
UNTIL pressed$><""
REM Now begin main part of program...
REPEAT REM Drives outer loop
REM Start of first pass through inner parts
REPEAT
PRINT ci$;
pressed$=INKEY$(2)
WAIT(delay%)
UNTIL pressed$><"":REMpressed$="." OR pressed$=","
REM Done?
IF pressed$="q" OR pressed$="Q" THEN
PRINT
PRINT "Bye"
WAIT(120)
QUIT
ENDIF
REPEAT
PRINT ch$;
pressed$=INKEY$(2)
WAIT(delay%)
UNTIL pressed$><""
REM Done?
IF pressed$="q" OR pressed$="Q" THEN
PRINT
PRINT "Bye"
WAIT(120)
QUIT
ENDIF
REM End of inner parts
REM *crude* "Do inner parts again" by copy/paste...
REM========= VVV Second copy of "inner parts" vvv
REPEAT
PRINT co$;
pressed$=INKEY$(2)
WAIT(delay%)
UNTIL pressed$><"":REMpressed$="." OR pressed$=","
REM Done?
IF pressed$="q" OR pressed$="Q" THEN
PRINT
PRINT "Bye"
WAIT(120)
QUIT
ENDIF
REPEAT
PRINT ch$;
pressed$=INKEY$(2)
WAIT(delay%)
UNTIL pressed$><""
REM Done?
IF pressed$="q" OR pressed$="Q" THEN
PRINT
PRINT "Bye"
WAIT(120)
QUIT
ENDIF
REM========= ^^^ Second copy of "inner parts" ^^^
PRINT:REM Starts new line of Pressed/Not pressed characters
UNTIL 4=5 REM End of Outer loop.