Menu

KEY SCAN CODE F1-F4

Anonymous
2015-11-23
2015-11-24
  • Anonymous

    Anonymous - 2015-11-23

    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

     
    • Rob Hagemans

      Rob Hagemans - 2015-11-24

      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

       
  • Ronald Herrera

    Ronald Herrera - 2015-11-24

    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

     
    • Rob Hagemans

      Rob Hagemans - 2015-11-24

      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

       
  • Ronald Herrera

    Ronald Herrera - 2015-11-24

    Thank You! It was my fault, really. I think the logic of the program didn't do what it supposed to.
    Ron.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.