Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
INKEY$ doesn't work with fixed length strings
#25
@SMcNeill
Quote:Why not just use variable length strings and not have the worry over it?
We finally come full circle. https://qb64phoenix.com/forum/showthread.php?tid=2889 and https://github.com/QB64-Phoenix-Edition/...issues/524

@Pete
(07-31-2024, 06:50 PM)Pete Wrote: @justsomeguy

If I had to make a workaround in my code, I'd need to do this...

Code: (Select All)
Type tt
    ' Use 2 bytes to capture 2 byte combinations
    k As String * 2
End Type
Dim As tt t
Do
    _Limit 30
    t.k = Chr$(0) + Chr$(0) ' This line and the MID$() line below clears up the issue. Space bar can now be detected.
    Mid$(t.k, 1, 2) = InKey$
    If t.k <> Chr$(0) + Chr$(0) Then
        Print Mid$(t.k, 1, 1), Mid$(t.k, 2, 1), Asc(Mid$(t.k, 1, 1)), Asc(Mid$(t.k, 2, 1))
    End If
Loop

Pete

Good job! It works well.
Reply


Messages In This Thread
RE: INKEY$ doesn't work with fixed length strings - by justsomeguy - 08-01-2024, 01:49 PM



Users browsing this thread: 6 Guest(s)