'ON TIMER will be used to erase a message
'five seconds after it has been printed.
'
'Set up "K" to use the ON KEY(n) statement.
'
KEY 18, CHR$(&H60) + CHR$(&H25) '<NUMLOCK> + <CAPSLOCK> + <K>
PRINT " THIS IS USED TO DEMONSTRATE A PROBLEM THAT EXISTS IN QB64 WHEN" PRINT " 'ON TIMER' AND 'ON KEY' ARE USED TOGETHER IN THE SAME PROGRAM." PRINT " Press 'T' for a message to appear and a 5 second TIMER cycle to start." PRINT " After 5 seconds the message is replaced and a counter will be updated." PRINT " Do this 2 or 3 times and wait for the counter to update each time." PRINT " Next, press 'K' and a differnt message and counter SHOULD appear..." PRINT " ...but the counter for the timer routine counts up INSTEAD." PRINT " This will happen for as many times as 'T' was pressed earlier," PRINT " and THEN the correct subroutine for 'ON KEY' will be used." PRINT " The steps above can be repeated without restarting the program." PRINT " This demo works without any problems in QB4.5 but not in QB64."
PRINT "Press 'T' to use the ON TIMER subroutine." PRINT "Press 'K' to use the ON KEY subroutine." PRINT "Press 'Q' to quit."
REM ----- (SUBROUTINE
) -- Display a message
and turn
on the
timer.
'
PRINT " --> The TIMER ON command has just been used. ";
PRINT " After 5 seconds the counter will be updated ";
PRINT " and the TIMER OFF command will be used. ";
REM -- Quit this program.
'
'Disable the TIMER and erase the message after 5 seconds is up.
'
TIMERnum = TIMERnum + 1
PRINT "The TIMER OFF command was just used ---------> this counter ="; TIMERnum
'
6000 KEYnum = KEYnum + 1
PRINT "You are in the ON KEY subroutine ------------> this counter ="; KEYnum