QB64 Phoenix Edition
Linux Lubuntu INKEY$ issue - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Linux Lubuntu INKEY$ issue (/showthread.php?tid=3924)



Linux Lubuntu INKEY$ issue - TempodiBasic - 09-08-2025

Hi Folks
I'm a beginner to Lubuntu, but this my notebook has born again with this OS, so I'm surfing the Linux sea.
Well, I hope there are many users of QB64pe on Linux. 
Here a my first question:
have you the same issue I've got with INKEY$ keyword too?

[Image: ascii-INKEY-in-Lubuntu.jpg]

this is the code:
Code: (Select All)
Screen 0
_ControlChr Off
Do
    Print " Press key for seeing the code turned back by INKEY$, Enter key will quit"
    Sleep
    a$ = InKey$
    Print a$;
    If Len(a$) > 1 Then Print " = CHR$(0) + CHR$(" + Str$(Asc(a$, 2)) + ")" Else Print " = " + Str$(Asc(a$))
Loop Until a$ = Chr$(13)
waiting Linux users' answers
Thanks


RE: Linux Lubuntu INKEY$ issue - ahenry3068 - 09-08-2025

I'm not sure what Issue it is your talking about.   Code seems to run fine for me ????


RE: Linux Lubuntu INKEY$ issue - SMcNeill - 09-08-2025

Wouldn't a null string produce the error?

No key pressed, a$ = ""
Len(a$) = 0 so triggers the ELSE.

ASC("") = ILLEGAL FUNCTION CALL


RE: Linux Lubuntu INKEY$ issue - Rudy M - 09-09-2025

(09-08-2025, 09:50 PM)TempodiBasic Wrote: Hi Folks
I'm a beginner to Lubuntu, but this my notebook has born again with this OS, so I'm surfing the Linux sea.
Well, I hope there are many users of QB64pe on Linux. 
Here a my first question:
have you the same issue I've got with INKEY$ keyword too?

[Image: ascii-INKEY-in-Lubuntu.jpg]

this is the code:
Code: (Select All)
Screen 0
_ControlChr Off
Do
    Print " Press key for seeing the code turned back by INKEY$, Enter key will quit"
    Sleep
    a$ = InKey$
    Print a$;
    If Len(a$) > 1 Then Print " = CHR$(0) + CHR$(" + Str$(Asc(a$, 2)) + ")" Else Print " = " + Str$(Asc(a$))
Loop Until a$ = Chr$(13)
waiting Linux users' answers
Thanks



RE: Linux Lubuntu INKEY$ issue - Rudy M - 09-09-2025

Hi, I'm working on an old Lenovo PC (but with 8Gb ram) and with Linux Mint 22, xfce4 as desktop.
In QB64pe your listing runs without error on my PC

Greatings,
Rudy M


RE: Linux Lubuntu INKEY$ issue - SMcNeill - 09-09-2025

You guys are terrible code testers.  You must hit something like "ABC123" and then yell, "EUREKA, IT WORKS!!"  Big Grin

Code: (Select All)
Screen _NewImage(120, 50, 0)
Color 15
Do
    Print " Press key for seeing the code turned back by INKEY$, Enter key will quit"
    Sleep
    a$ = InKey$
    Print a$;
    If Len(a$) > 1 Then
        Print " = CHR$(0) + CHR$(" + Str$(Asc(a$, 2)) + ")"
    ElseIf Len(a$) = 0 Then
        Color 4
        Print "= You pressed a key which would break SLEEP but not be recorded as an INKEY$ keypress."
        Print "I would guess that was SHIFT, ALT, or CONTROL."
        Print "Am I right?"
        Color 15
    Else
        Print " = " + Str$(Asc(a$))
    End If
    Print
Loop Until a$ = Chr$(13)

Give that a run.  Linux.  Mac.  Windows.  I don't care.  It illustrates and explain the error easily for everyone to grasp what's going on here.

It's precisely as I said above:  You can't take the ASC of a null string.   

ASC("") = ILLEGAL FUNCTION CALL.


RE: Linux Lubuntu INKEY$ issue - TempodiBasic - 09-09-2025

Thanks for replies
@All
 I got the issue on the combo keys or using Shift to change from Uppercase to lowercase and vice versa!

@SMcNeill

Amazing Steve!
You fire the centre of issue.

Yeah I have made a mistake!
I missed your suggestion about ASC because the row of code starts with IF LEN (a$)>1... BuuuuuuuuuT
in the ELSE case it goes also a$="" when a keystroke with Alt/Ctrl or Shift gives the event with no value returned by INKEY$!

so the solution is another IF in the ELSE case

Code: (Select All)

Screen 0
_ControlChr Off
Do
    Print " Press key for seeing the code turned back by INKEY$, Enter key will quit"
    Sleep
    a$ = InKey$
    Print a$;
    If Len(a$) > 1 Then
        Print " = CHR$(0) + CHR$(" + Str$(Asc(a$, 2)) + ")"
    Else
        If Len(a$) > 0 Then Print " = " + Str$(Asc(a$))
    End If
Loop Until a$ = Chr$(13)

Steve your code is clear and selfexplaining!


RE: Linux Lubuntu INKEY$ issue - hsiangch_ong - 09-09-2025

only if totally stupid, antiquated asc() function were like the one in freebasic.

the antiquated function really might be inkey$.  cannot rely on it obviously.  in a game with 3d graphics.  or anything really which supports a player's "sharp senses."

don't use sleep in this programming system.  there wouldn't be a need for _keyclear and other antics.  only to clear the keyboard buffer.  when there's no need to know what was the key pressed.

i haven't checked lately.  but there was a time.  when sleep consumed serious cpu cycles when left to its own in the "mainwin."