Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
INKEY$ doesn't work with fixed length strings
#7
(07-28-2024, 04:07 PM)SMcNeill Wrote: Works as expected.  Try this:

...

The issue is you're printing it in an loop.  You press "A", it pops up on the screen for a poop, and then the loop just keeps repeating, and it's replaced almost instantly by nothing as it waits for the next keypress to poop up the next key being processed.
Wow, missing out on that porta-potty contract is really eating at you!

Pete Big Grin 

- I'm in with the INKEY$ crowd!

EDIT: @justsomeguy

I don't use a dim as string approach with INKEY$, I noticed this approach makes a null string as CHR$(32) + CHR$(32). That will be problematic if you intend to trap a spacebar press.

Code: (Select All)
Type tt
    ' Use 2 bytes to capture 2 byte combinations
    'k AS STRING ' Works
    k As String * 2 ' Does Not work
End Type

Dim As tt t

' Note you cannot detect a spacebar press with this 'Dim as String' approach.
Do
    t.k = InKey$
    If Len(LTrim$(t.k)) Then
        Locate 1, 1
        Print "k:"; t.k, Asc(Mid$(t.k, 1, 1)), Asc(Mid$(t.k, 2, 1)); "  "; ' Cover up larger output strings.
    End If
Loop
Reply


Messages In This Thread
RE: INKEY$ doesn't work with fixed length strings - by Pete - 07-29-2024, 06:12 PM



Users browsing this thread: 9 Guest(s)