Qbasicnews.com

Full Version: input to asci
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
is there a way to translate inputed keys to their asci numeric value?
Code:
DO
CLS
press$ = INKEY$
LOCATE 1,1 : PRINT press$
SLEEP
LOOP

Anonymous

just do like

Code:
Pr = ASC(Press$)

Pr equals the ascii value of Press$

(It's like the opposite of CHR$())
*illiegal function call*
ok i think it's saying that becausethe fis second it runs there is no data. feed it dummy data until press$=inkey$ ? it is an issue wiht there being no data. so how do ya make it work??
Code:
IF Pres$<>"" then Pr = ASC(Pres$) else Pr = 0

or

Code:
Pr = INP (&H60)
AFAIK, it's better to do this when reading from port 60h:

Code:
FUNCTION neoKeybInkeyScan%
   k% = INP(&H60)
   IF k% > 128 THEN neoKeybInkeyScan% = 0 ELSE neoKeybInkeyScan% = k%
END FUNCTION

Because port 60h tends to return non-zero values even when no keys is being pressed. If that's so, check for the limit of 128, and if so, there's no key being pressed.

But... this function returns Scan Codes, not ASCII codes (na_th_an.... Wink)
lol
you're right
hahaha

Personal note: Don't ever post at 8:00 am Big Grin
Quote:lol
you're right
hahaha

Personal note: Don't ever post at 8:00 am Big Grin
Wow, you're up that early! Wink

About the personal note... [Image: new_rofl.gif]
What I do with INKEY$, if I use it, is I split it up into three parts, like so:

Code:
DO
i$ = INKEY$
IF i$ <> "" THEN
IF LEN(i$) = 2 THEN
SELECT CASE ASC(MID$(i$, 2, 1))
CASE 77: EXIT DO 'That's the right arrow key
END SELECT

ELSE

SELECT CASE ASC(i$)
CASE 27: EXIT DO 'That's <esc>
END SELECT
END IF

END IF
'do stuff that you would do regardless of any keys pressed...
LOOP

Anonymous

dood u got the nuttiest lookin code i ever seen Smile its all good tho
:o :o :o Apparently you haven't seen a lot of code.. . . . ...
Pages: 1 2