Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linux Lubuntu INKEY$ issue
#1
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
Reply
#2
I'm not sure what Issue it is your talking about.   Code seems to run fine for me ????
Reply
#3
Wouldn't a null string produce the error?

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

ASC("") = ILLEGAL FUNCTION CALL
Reply
#4
(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
Reply
#5
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
Reply
#6
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.
Reply
#7
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!
Reply
#8
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."
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Don't let INKEY$ byte you in the ASCII Pete 1 160 02-01-2026, 10:44 PM
Last Post: PhilOfPerth
  Make windows .exe using Linux version? Circlotron 7 478 01-15-2026, 09:42 PM
Last Post: ahenry3068
  Linux - file dialogue boxes... atl068 7 888 08-05-2025, 07:21 PM
Last Post: hsiangch_ong
  System Linux Chris 9 1,173 07-12-2025, 08:51 PM
Last Post: Chris
  Linux: terminal output Parkland 4 819 06-08-2025, 04:00 PM
Last Post: DSMan195276

Forum Jump:


Users browsing this thread: 1 Guest(s)