Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBC] Scancode to letter or symbol

Author
Message
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 24th Jul 2009 04:39 Edited at: 24th Jul 2009 04:43
This code takes a scancode and returns the letter/symbol it represents.

I know it seems just like the inkey$() command but the bonus to my code is that you can return more then just one letter/symbol.

Here's the code:



Here's an example of how it works and how it can return more then one key pressed at once:

NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 9th Aug 2009 23:17
Slow, slow, slow. You're doing all those comparisons in the least efficient way possible. You're not escaping as soon as the variable is determined, and a case/select would be much cleaner.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 10th Aug 2009 03:37 Edited at: 10th Aug 2009 03:37
Yes, you should use an array instead, where each index is filled with a corresponding character. Then once you have the scancode you're trying to convert to a character you can just look it up in the array--no conditions (if-statements) needed.

i like orange
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 17th Aug 2009 23:05
An array is crucial. u need to us- oh, you alrady got flamed for that srry, cool tho.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
jeffhuys
17
Years of Service
User Offline
Joined: 24th May 2006
Location: No cheesy line here.
Posted: 24th Aug 2009 11:38
I find it better to define constants (DIK_A, DIK_B etc.) and use them as scancodes.

You're the 'th to view this signature!
Jeko
14
Years of Service
User Offline
Joined: 29th Jun 2009
Location: On TGC Forum
Posted: 31st Aug 2009 01:53 Edited at: 31st Aug 2009 01:56
here is the simplier code


edited: so you do not looking for scancode program

Ja sam ja.Ti si ti. Ko je ko?

Login to post a reply

Server time is: 2024-05-05 00:27:13
Your offset time is: 2024-05-05 00:27:13