Qbasicnews.com

Full Version: Challenge: ScanCode() routine
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
You know the ASC() function? well this challenge is to make a ScanCode() function, more points for small code, code clarity, and speed.

example useage:

Scancode.A = ScanCode("A")
Print Scancode.A

should output 30 or &H1E.

The contest will end, the 23rd at 12am (your timezone).
this should be more then enuff time.

Either PM your entrys to me or wait until the 23rd and post em.
...So basically make your own ASC() function?
there is a slightly buggy reverse scancode function here.

http://faq.qbasicnews.com/?blast=ChrTwo
Quote:...So basically make your own ASC() function?
Not exactly. All the keys on your keyboard have scan codes, but only some of then have ascii codes. Like shift, for example. Shift has a scan code but no ascii code.
Hmm.. a use for my string btree searcher? Big Grin
What exactly did the string btree searcher do, i neva ran the code?
wel ll you should.
Quote:
Zack Wrote:...So basically make your own ASC() function?
Not exactly. All the keys on your keyboard have scan codes, but only some of then have ascii codes. Like shift, for example. Shift has a scan code but no ascii code.
Gotcha.
*Zack runs with tail between legs*
Beyond the scope of my skills.. Smile
I was making one with the btree searcher but unfortunately it takes some modification. The biggest problem is that the scancode repeats strings but the btree doesn't and i'll need to add another array to it..
Zack, This is the list of scan codes from the help file in QB 7.1:
Code:
File  Edit  View  Search  Run  Debug  Calls  Utility  Options          Help
+------------------------- HELP: Keyboard Scan Codes ----------------------¦+-+
¦                                                 Contents  Index  Back  
¦------------------------------------------------------------------------------_
¦      Key     Code      Â¦    Key         Code    Â¦     Key       Code         _
¦                        Â¦                        Â¦
¦      Esc        1      Â¦    A           30      Â¦     F1          59         _
¦      ! or 1     2      Â¦    S           31      Â¦     F2          60         _
¦      @ or 2     3      Â¦    D           32      Â¦     F3          61         _
¦      # or 3     4      Â¦    F           33      Â¦     F4          62         _
¦      $ or 4     5      Â¦    G           34      Â¦     F5          63         _
¦      % or 5     6      Â¦    H           35      Â¦     F6          64         _
¦      ^ or 6     7      Â¦    J           36      Â¦     F7          65         _
¦      & or 7     8      Â¦    K           37      Â¦     F8          66         _
¦      * or 8     9      Â¦    L           38      Â¦     F9          67         _
¦      ( or 9    10      Â¦    : or ;      39      Â¦     F10         68         _
¦      ) or 0    11      Â¦    " or '      40      Â¦     F11        133         _
¦      _ or -    12      Â¦    ~ or `      41      Â¦     F12        134         _
¦      + or =    13      Â¦    Left Shift  42      Â¦     NumLock     69         _
¦      Bksp      14      Â¦    | or \      43      Â¦     Scroll Lock 70         _
¦      Tab       15      Â¦    Z           44      Â¦     Home or 7   71         _
¦      Q         16      Â¦    X           45      Â¦     Up or 8     72         _
¦      W         17      Â¦    C           46      Â¦     PgUp or 9   73         _
¦      E         18      Â¦    V           47      Â¦     Gray -      74         _
¦      R         19      Â¦    B           48      Â¦     Left or 4   75         _
¦      T         20      Â¦    N           49      Â¦     Center or 5 76         _
¦      Y         21      Â¦    M           50      Â¦     Right or 6  77         _
¦      U         22      Â¦    < or ,      51      Â¦     Gray +      78         _
¦      I         23      Â¦    > or .      52      Â¦     End or 1    79         _
¦      O         24      Â¦    ? or /      53      Â¦     Down or 2   80         _
¦      P         25      Â¦    Right Shift 54      Â¦     PgDn or 3   81         _
¦      { or [    26      Â¦    Prt Sc or * 55      Â¦     Ins or 0    82         _
¦      } or ]    27      Â¦    Alt         56      Â¦     Del or .    83         _
¦      Enter     28      Â¦    Spacebar    57      Â¦                            _
¦      Ctrl      29      Â¦    Caps Lock   58      Â¦                            _
¦                                                                              _

Binary,
your input to the function appears to be a string. If this is correct, what strings should be used for non-character keys.
Pages: 1 2