_Inkey from 4UTILS

Hey @vefatica,
I cannot get _Inkey to recognize the spacebar;
Code:
:: _inkey is from 4UTILS plugin
::
@setlocal
@echo off
do forever
  set theKey=%_inkey
    switch %theKey
    case 0
      delay /m 100
    case @8
      Gosub Backspace
    case @13
      echo Enter
      leave
    case @32
      Gosub Spacebar
    case @62
      Gosub F4
    endswitch
enddo
endlocal
quit

:Backspace
  echo Backspace
Return

:F4
  echo F4
Return

:Spacebar
  echo Spacebar
Return

It would be helpful if _Inkey would recognize the Spacebar (032).

Joe
 
May 20, 2008
12,049
128
Syracuse, NY, USA
Well, it does recognize it. But if you echo it you just get "ECHO IS OFF". And you can't test for it.

"@32" is a good idea (why didn't I think of that? :-). I'll make the change but it might take a while to go through 4UTILS and disable experimental and not_for_public_consumption things. In the meantime you can get the one I just put in ftp://vefatica.net's "experimental" directory. I don't think there's anything in it that will prevent it from working. There's no new TXT file so if you have an old one, keep it.

Code:
v:\> do forever (echo %_inkey & delay 1)
0
0
@32
0
0
 
May 20, 2008
12,049
128
Syracuse, NY, USA
Hey @Joe Caverly ...

_INKEY has other shortcomings. Here's how it works at the moment.

1. If 32 < c < 127 it gives the character. Like the spacebar, that could be problematic with the likes of backquote, double_quote, percent (and maybe others).

2. if 0 < c <= 32 it gives "@NN"

3. If c > 65536 it gives "@(c - 65536)". These could conflict with the ones in (2) (example: Ctrl-B (2) and CTRL_1 (also 2, see below)) because there are many like these (from TAKECMD.H, just to show a few):

Code:
#define FBIT 0x10000 // 65536)
#define CTRL_0        (11+FBIT)
#define CTRL_1        (2+FBIT)
#define CTRL_2        (3+FBIT)
#define CTRL_3        (4+FBIT)
(the list goes on)

4. For any other character it tries to print the character. This poses a few problems. Many Unicode characters (which can be entered with Alt-keypad) will be not printable (depending on font and code page).

So I'm wondering how I can make it more robust OR simpler.

Got any ideas?

Note that there are characters that _INKEY just doesn't see because Windows of something else gobbles them up.