input$() with num-keypad????

Blitz3D Forums/Blitz3D Programming/input$() with num-keypad????

Dimas(Posted 2007) [#1]
Is there anyone with a custom input$() function that can read numbers on the numerical key pad?

Thank you.


octothorpe(Posted 2007) [#2]
Something like this perhaps? http://www.blitzbasic.com/codearcs/codearcs.php?code=251


Dimas(Posted 2007) [#3]
No, I would like a input$() function but able to read numeric numbers from the little numeric keyboard on the right.


TygerWulf(Posted 2007) [#4]
So, take this code and make your own function like:

Function MY_Input$(x=0, y=0, prompt$="")

SetBuffer = BackBuffer()

KEY_register_printable_keys()

input_string$ = ""
While Not KeyHit(1)
char = KEY_GetKey()
If char > 0 Then input_string$ = input_string$ + Chr$(char)

Locate x, y
Print prompt$
Print input_string$ + cursor$
Flip
Wend

return input_string$

End Function

And call MY_input(...) whenever you would have called input. The code could do with some work, and I haven't used B3d in years, but it should do something like what you're looking for. The code that Octothorpe gave you is probably very similar to how Input$() works, it just doesn't have the scancodes for the numpad working. I don't know how well the code would work on a foreign keyboard or on a DVORAK keyboard, though. As an added bonus, I made the function positional, but I'm sure that the locate command can just be removed if you don't want it to work that way. I hope I helped some, and I hope that I didn't completely mangle B3d code to do it =^_^=