I just built this for my project, and I bet some people would benefit from it. I believe I have all my scancodes correct, if not, please correct them
Function:
Rem Declare these variables at the top
Global Key_Input `globals for input
Global ReturnString$
Global S_value$
Rem Input Function ***************************
Function Menu_Input(String_I$)
If Key_Input<>Scancode() `check for keyspam
Rem Check For Key and set value **************
Select Scancode()
Case 2 : S_value$="1" : EndCase
Case 3 : S_value$="2" : EndCase
Case 4 : S_value$="3" : EndCase
Case 5 : S_value$="4" : EndCase
Case 6 : S_value$="5" : EndCase
Case 7 : S_value$="6" : EndCase
Case 8 : S_value$="7" : EndCase
Case 9 : S_value$="8" : EndCase
Case 10 : S_value$="9" : EndCase
Case 11 : S_value$="0" : EndCase
Case 16 : S_value$="Q" : EndCase
Case 17 : S_value$="W" : EndCase
Case 18 : S_value$="E" : EndCase
Case 19 : S_value$="R" : EndCase
Case 20 : S_value$="T" : EndCase
Case 21 : S_value$="Y" : EndCase
Case 22 : S_value$="U" : EndCase
Case 23 : S_value$="I" : EndCase
Case 24 : S_value$="O" : EndCase
Case 25 : S_value$="P" : EndCase
Case 30 : S_value$="A" : EndCase
Case 31 : S_value$="S" : EndCase
Case 32 : S_value$="D" : EndCase
Case 33 : S_value$="F" : EndCase
Case 34 : S_value$="G" : EndCase
Case 35 : S_value$="H" : EndCase
Case 36 : S_value$="J" : EndCase
Case 37 : S_value$="K" : EndCase
Case 38 : S_value$="L" : EndCase
Case 43 : S_value$="Z" : EndCase
Case 44 : S_value$="X" : EndCase
Case 45 : S_value$="C" : EndCase
Case 46 : S_value$="V" : EndCase
Case 47 : S_value$="B" : EndCase
Case 48 : S_value$="N" : EndCase
Case 49 : S_value$="M" : EndCase
Case Default : S_value$="" : EndCase
EndSelect
Rem Create ReturnString **********************
ReturnString$=String_I$+S_value$
Rem Creat ReturnString w/ Space **************
If Spacekey()=1 Then ReturnString$=ReturnString$+" "
Rem Delete Character *************************
If Keystate(14)=1 `check for backspace
delete=LEN(ReturnString$)-1 : If delete<0 Then delete=0
ReturnString$=Left$(ReturnString$,delete)
Endif
Endif
Key_Input=Scancode() `set key_input variable
EndFunction ReturnString$
Usage Example:
do
set cursor 0,0
Print "Name: ";Name$
Print "Age: ";Age
Rem Do a String Input
Name$ = Menu_Input(Name$)
Rem Or do a Variable Input
Age = VAL(Menu_Input(STR$(Age)))
sync
loop
you'll have to setup someway to know when to update what variable, so your not accidentally updating all your variables at once, lol. You can also add more characters if you want, just add more cases with the correct scancode() and string representation of the key. I had this limited for my own project needs, but people can add whatever they want. Hope this benefits people.
edit:
if all the commands exist in DBC, then there should be no reason why it shouldn't work in DBC. If someone can test it and report, that would be awesome.
BWM
"I wish I was a wizard, becuase then I could wave my wand and perfect code would just appear."