Qbasicnews.com

Full Version: Help for a friend
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
my friend dosen't have the internet and wants to know

what the ascii character codes for ALT+s is and ALT+Q

thanx
Alt-S is CHR$(0) + CHR$(31)
Alt-Q is CHR$(0) + CHR$(16)

You can write a simple program to find out other ones as well...
Code:
CLS
DO
  k$ = INKEY$
  IF LEN(k$) = 1 THEN
    CLS
    LOCATE 1, 1
    PRINT k$ + " ";
    LOCATE 2, 1
    PRINT "CHR$(" + LTRIM$(STR$(ASC(k$))) + ")";
  ELSEIF LEN(k$) = 2 THEN
    CLS
    LOCATE 1, 1
    PRINT k$;
    LOCATE 2, 1
    PRINT "CHR$(" + LTRIM$(STR$(ASC(k$))) + ") + CHR$("+ LTRIM$(STR$(ASC(RIGHT$(k$, 1)))) + ")";
  END IF
LOOP WHILE k$ <> CHR$(27)
that will help hime alot thanx
Ascii Alt-Q and ascii Alt-S do not exist.
What Plasma357 put in his answer are the INKEY$ function return codes.And that's not the same than the keyboard sacan codes, that would be different. But nothing is defined in ASCII for Alt-Q and Alt-S.
Right, Antoni, a very important point.

Said another way, QB can identify Alt-Q and Alt-S combination keys via the QB INKEY$ function. But these combination keys are NOT part of the Ascii character set, and INKEY$ has to identify these by using 2 bytes, where for a real Ascii character it only needs to use 1 byte.

As a matter of fact, if I'm not mistaken, none of the combinations with ALT are represented in Ascii code. This means that if you wanted to save the Alt-anykey combination anywhere on a file, for example, you would have to use a two byte scheme to do this, which could get very tedious.
*****
It only gets tedious if you have to remake the function for each program... unless you use modules/libs....

One of my current programs supports two-character combos...... I'm using INP(96) for now... but it is a pain.......
But Plasma's code handles two byte ASCII codes. You see the 'elseif'??? There you go