I’m having difficulties with the scan codes for the functions key in PC-BASIC. Example if I trap F1 with its natural scan code CHR$(0) + CHR$(&H3B) it won’t allow it. Here’s a piece a program that works on GWBASIC:
10 'CONFIGURING KEY SCAN CODE FROM F1 TO F4
20 KEY 1, CHR$(0) + CHR$(&H3B)
30 KEY 2, CHR$(0) + CHR$(&H3C)
40 KEY 3, CHR$(0) + CHR$(&H3D)
50 KEY 4, CHR$(0) + CHR$(&H3E)
60 K$ = INKEY$: IF K$=CHR$(27) THEN END: '<Esc>=Quit
70 IF K$ = CHR$(0) + CHR$(&H3B) THEN PRINT "F1-OK"
80 IF K$ = CHR$(0) + CHR$(&H3C) THEN PRINT "F2-OK"
90 IF K$ = CHR$(0) + CHR$(&H3D) THEN PRINT "F3-OK"
100 IF K$ = CHR$(0) + CHR$(&H3E) THEN PRINT "F4-OK"
110 GOTO 60
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The code you posted works correctly for me on PC-BASIC 15.08.1 on both Windows 7 and Ubuntu Linux: it responds to the function keys F1-F4 by printing F1-OK etc., and exits on the Esc key.
What is your operating system? What happens when you press the function keys?
On some OSes you may need to run in fullscreen (press F11+F in the graphical interface or run with the --fullscreen=True option) so that the OS can't catch the function keys before PC-BASIC does.
Thanks
Rob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I keep forgetting to login. And yes, I tried this time with a fresh PCBASIC windows and it worked as it supposed to; I’m very sorry for this. My Bad! I think something that I had done, which I can’t remember what it was (e.g. a wrong DEF SEG, POKE, etc.) that I have alter PCBASIC functions and it wouldn’t answer to the program. I’ll try to follow up the steps to see what went wrong, could be a normal operation as it, or could be signs of a bug. But for the time been thank you for your patience. If I duplicate the steps, I'll keep you in touch, and you can decide if it needs attention or is a normal behavior.
Ronald
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, thanks for the update! I did find a related bug - the above code should also work if the key definitions in lines 20-50 are empty strings, but it didn't at first. That's solved now, at least in the development branch.
POKE and related functions shouldn't really alter the behaviour of PC-BASIC: they do not actually write directly to memory as they do in GW-BASIC under DOS, whatever they do in PC-BASIC is all emulated and in fact quite limited. So if you are able to reproduce the original bug, do let me know.
Rob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "[CLOSED] General Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
I’m having difficulties with the scan codes for the functions key in PC-BASIC. Example if I trap F1 with its natural scan code CHR$(0) + CHR$(&H3B) it won’t allow it. Here’s a piece a program that works on GWBASIC:
10 'CONFIGURING KEY SCAN CODE FROM F1 TO F4
20 KEY 1, CHR$(0) + CHR$(&H3B)
30 KEY 2, CHR$(0) + CHR$(&H3C)
40 KEY 3, CHR$(0) + CHR$(&H3D)
50 KEY 4, CHR$(0) + CHR$(&H3E)
60 K$ = INKEY$: IF K$=CHR$(27) THEN END: '<Esc>=Quit
70 IF K$ = CHR$(0) + CHR$(&H3B) THEN PRINT "F1-OK"
80 IF K$ = CHR$(0) + CHR$(&H3C) THEN PRINT "F2-OK"
90 IF K$ = CHR$(0) + CHR$(&H3D) THEN PRINT "F3-OK"
100 IF K$ = CHR$(0) + CHR$(&H3E) THEN PRINT "F4-OK"
110 GOTO 60
Hi, thanks for getting in touch!
The code you posted works correctly for me on PC-BASIC 15.08.1 on both Windows 7 and Ubuntu Linux: it responds to the function keys F1-F4 by printing
F1-OK
etc., and exits on the Esc key.What is your operating system? What happens when you press the function keys?
On some OSes you may need to run in fullscreen (press F11+F in the graphical interface or run with the
--fullscreen=True
option) so that the OS can't catch the function keys before PC-BASIC does.Thanks
Rob
Hello, I keep forgetting to login. And yes, I tried this time with a fresh PCBASIC windows and it worked as it supposed to; I’m very sorry for this. My Bad! I think something that I had done, which I can’t remember what it was (e.g. a wrong DEF SEG, POKE, etc.) that I have alter PCBASIC functions and it wouldn’t answer to the program. I’ll try to follow up the steps to see what went wrong, could be a normal operation as it, or could be signs of a bug. But for the time been thank you for your patience. If I duplicate the steps, I'll keep you in touch, and you can decide if it needs attention or is a normal behavior.
Ronald
Hi, thanks for the update! I did find a related bug - the above code should also work if the key definitions in lines 20-50 are empty strings, but it didn't at first. That's solved now, at least in the development branch.
POKE
and related functions shouldn't really alter the behaviour of PC-BASIC: they do not actually write directly to memory as they do in GW-BASIC under DOS, whatever they do in PC-BASIC is all emulated and in fact quite limited. So if you are able to reproduce the original bug, do let me know.Rob
Thank You! It was my fault, really. I think the logic of the program didn't do what it supposed to.
Ron.