Page 1 of 1
I have a problem with INKEY$ and _DELAY
Posted: Tue Aug 23, 2016 5:17 pm
by Albert
Code: Select all
SCREEN _NEWIMAGE(800, 600, 32)
PRINT "Press ENTER to continue."
DO
LOOP UNTIL INKEY$ = CHR$(13)
_DELAY 1
PRINT "Press ENTER again to quit."
DO
LOOP UNTIL INKEY$ = CHR$(13)
in this example you can press enter twice without the second print being displayed but it still ends the application
if you didn't get the problem maybe u can test it out by yourself, THANK YOU IN ADVANCE !!!
Re: I have a problem with INKEY$ and _DELAY
Posted: Tue Aug 23, 2016 5:28 pm
by Albert
Albert wrote:Code: Select all
SCREEN _NEWIMAGE(800, 600, 32)
PRINT "Press ENTER to continue."
DO
LOOP UNTIL INKEY$ = CHR$(13)
_DELAY 1
PRINT "Press ENTER again to quit."
DO
LOOP UNTIL INKEY$ = CHR$(13)
in this example you can press enter twice without the second print being displayed but it still ends the application
idk if it's a bug or i if i just screwed up but i need some help
if you didn't get the problem maybe u can test it out by yourself, THANK YOU IN ADVANCE !!!
Re: I have a problem with INKEY$ and _DELAY
Posted: Tue Aug 23, 2016 5:43 pm
by burger2227
What are you trying to do? Worked for me.
Re: I have a problem with INKEY$ and _DELAY
Posted: Tue Aug 23, 2016 5:54 pm
by Albert
burger2227 wrote:What are you trying to do? Worked for me.
you can press enter twice without waiting for the delay and once the time passes it just ends the application
Re: I have a problem with INKEY$ and _DELAY
Posted: Tue Aug 23, 2016 7:52 pm
by burger2227
INKEY$ reads the keyboard buffer. IE the buffer holds the keys pressed until read.
Code: Select all
PRINT "Press ENTER to continue."
DO
LOOP UNTIL INKEY$ = CHR$(13)
_DELAY 2
PRINT "Press ENTER again to quit."
DO
PRINT INKEY$;
LOOP UNTIL INKEY$ = CHR$(13)
Press all the keys you want during the delay and see what is printed. SLEEP will keep the keys in the buffer too.
To clear the buffer use: DO UNTIL INKEY$ = "": LOOP
Otherwise an INPUT later may pick up the extra key presses.
Re: I have a problem with INKEY$ and _DELAY
Posted: Wed Aug 24, 2016 5:08 am
by Albert
burger2227 wrote:INKEY$ reads the keyboard buffer. IE the buffer holds the keys pressed until read.
Code: Select all
PRINT "Press ENTER to continue."
DO
LOOP UNTIL INKEY$ = CHR$(13)
_DELAY 2
PRINT "Press ENTER again to quit."
DO
PRINT INKEY$;
LOOP UNTIL INKEY$ = CHR$(13)
Press all the keys you want during the delay and see what is printed. SLEEP will keep the keys in the buffer too.
To clear the buffer use: DO UNTIL INKEY$ = "": LOOP
Otherwise an INPUT later may pick up the extra key presses.
this solved my problem, thank you!
btw I found _KEYCLEAR command and I think it's easier to use it than what you taught me
ty again