Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The program only wants to run once . . .
#13
@Jack

Good to know. SLEEP does work with INKEY$, but it has to be before the INKEY$ statement. _KEYHIT will not return a key value after either _DELAY or SLEEP.

Code: (Select All)
Print "Press a key within 2-seconds...": Print
Sleep 2 ' Allows for the key to be trapped.
b$ = InKey$
_Delay 1
Print
Print "Press a key within 2-seconds again...": Print
_Delay 2 ' _Dealy or Sleep with _KEYHIT does not return a value.
a = _KeyHit
Print "INKEY$: b$ = "; b$
Print "_KEYHIT: a = "; a$
Print
Print "Press Esc to quit"
Do: _Limit 10: Loop Until InKey$ = Chr$(27)
System

Of course putting a SLEEP statement in has its advantages/disadvantages with a timing condition, as SLEEP (anything) is disengaged the moment a key is pressed, unlike _DELAY, which waits the full coded time before proceeding.

There are just a couple of instances that I would prefer using _KEYHIT and Since I don't use SLEEP in my programs, that would never be an issue. For me it's a familiarity issue. Coding with INKEY$ is super fast, almost completely intuitive. With _KEYHIT I have to keep guessing what the hell key it is when reading the code.

Pete

- I think the Dems are trying to scare us, first with Biden now with Harris.
Reply


Messages In This Thread
RE: The program only wants to run once . . . - by Pete - 07-31-2024, 02:37 AM



Users browsing this thread: 1 Guest(s)