Qbasicnews.com
August 25, 2019, 11:28:37 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Challenge: ScanCode() routine  (Read 6079 times)
BinarySHOCK
Forum Regular
**
Posts: 117



WWW
« on: January 16, 2004, 06:15:43 AM »

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.
Logged

very F***ing song remains the same
To everyone who sucks-up for the fame
Out of strength you know we speak the truth
Every trend that dies is living proof

MasterMinds Software
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #1 on: January 16, 2004, 10:44:05 AM »

...So basically make your own ASC() function?
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #2 on: January 16, 2004, 09:14:00 PM »

there is a slightly buggy reverse scancode function here.

http://faq.qbasicnews.com/?blast=ChrTwo
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #3 on: January 16, 2004, 11:44:02 PM »

Quote from: "Zack"
...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.
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #4 on: January 17, 2004, 06:48:55 PM »

Hmm.. a use for my string btree searcher?  Cheesy
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
BinarySHOCK
Forum Regular
**
Posts: 117



WWW
« Reply #5 on: January 17, 2004, 07:31:03 PM »

What exactly did the string btree searcher do, i neva ran the code?
Logged

very F***ing song remains the same
To everyone who sucks-up for the fame
Out of strength you know we speak the truth
Every trend that dies is living proof

MasterMinds Software
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #6 on: January 17, 2004, 08:49:43 PM »

wel ll  you should.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #7 on: January 17, 2004, 08:56:42 PM »

Quote from: "Sterling Christensen"
Quote from: "Zack"
...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.. Smiley
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #8 on: January 17, 2004, 09:11:43 PM »

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..
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
SCM
Wandering Guru
***
Posts: 311



« Reply #9 on: January 20, 2004, 04:06:03 PM »

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.
Logged

hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #10 on: January 20, 2004, 04:35:29 PM »

I used "SHIFT", "BACKSPACE", etc. in my unfinished version.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
BinarySHOCK
Forum Regular
**
Posts: 117



WWW
« Reply #11 on: January 23, 2004, 02:48:38 AM »

Ya just follow what agamemnus suggested..
Logged

very F***ing song remains the same
To everyone who sucks-up for the fame
Out of strength you know we speak the truth
Every trend that dies is living proof

MasterMinds Software
SCM
Wandering Guru
***
Posts: 311



« Reply #12 on: January 30, 2004, 09:32:00 PM »

Were there any submissions?
Logged

hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #13 on: January 30, 2004, 10:02:28 PM »

no...
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Frognik
New Member

Posts: 1


« Reply #14 on: February 08, 2004, 12:51:46 PM »

INP(96) returns keyboard scancodes

CLS
WHILE keynumber% <> 1     'ESC = 1
keynumber% = INP(96)
LOCATE 1, 1: PRINT "The number of the key being pressed is"; keynumber%; " "
LOCATE 2, 1: PRINT "(Press some keys)"
WEND
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!