09-15-2024, 01:21 PM
Tried doing a little program. Wanted to use the cursor keys as movement (left, right, up and down) followed by enter when done. _Inkey$ wasn't going to work for me.
Came upon _Keyhit. A value is returned as key codes. Nice. Until I used it.
Grab a key code input: (Q would abort the program)
Do
_Limit 5
x = _KeyHit
If x = 81 Or x = 113 Then End
If x < 0 Then x = 0
If x <> 0 Then Exit Do
Loop
' do some wild and interesting things here based upon cursor keys, unimportant to the my problem.
' exiting here after the magic
' the main block code is executed twice once as a test run then the real thing
If testrun = 0 Then End
*** insert below code here to fix it ***
Input "hit enter to start the real run or anything to quit"; a$
If a$ = "" Then testrun = 0: GoTo reruntop
The above line is the last line of code. Which would default "end" if anything is input except just enter.
The devilishly evil thing about _Keyhit, which I assumed and didn't realize. It's nothing like Inkey$
_Keyhit returns key codes, but does not modify the keyboard buffer when a key code is observed.
aka: Schrödinger's cat is still in the box re:keyboard buffer. Wither you looked or not.
Happy ending. Do this before next input requirement:
Do
a$ = InKey$
Loop Until a$ = ""
Happy trails.
Came upon _Keyhit. A value is returned as key codes. Nice. Until I used it.
Grab a key code input: (Q would abort the program)
Do
_Limit 5
x = _KeyHit
If x = 81 Or x = 113 Then End
If x < 0 Then x = 0
If x <> 0 Then Exit Do
Loop
' do some wild and interesting things here based upon cursor keys, unimportant to the my problem.
' exiting here after the magic
' the main block code is executed twice once as a test run then the real thing
If testrun = 0 Then End
*** insert below code here to fix it ***
Input "hit enter to start the real run or anything to quit"; a$
If a$ = "" Then testrun = 0: GoTo reruntop
The above line is the last line of code. Which would default "end" if anything is input except just enter.
The devilishly evil thing about _Keyhit, which I assumed and didn't realize. It's nothing like Inkey$
_Keyhit returns key codes, but does not modify the keyboard buffer when a key code is observed.
aka: Schrödinger's cat is still in the box re:keyboard buffer. Wither you looked or not.
Happy ending. Do this before next input requirement:
Do
a$ = InKey$
Loop Until a$ = ""
Happy trails.