Posted: 14th May 2003 11:25
yo, i whipped this up in response to someone needing help in the forums, so if ya missed it there, here it is again

this uses the windows buffer for getting keypresses, advantage is that no matter the speed of a user system or their typing speed, it will get exactly what they enter, also allows you to limit the amount of input (in the example it is set to 20)

enjoy!

+ Code Snippet
sync on

`make sure text$ is global or the function will fail!!
global text$ as string

main:
text$=""
clear entry buffer
intext$=""

while intext$=""
   cls
   center text 320,50,"enter your string"
   center text 320,100,text$
   ` 20= max number of chars for string - change to whatever
   intext$=_CheckInput(20)
   sync
endwhile

cls
print "Restarting Loop"
print "Your Last Input > ";intext$
sync
wait 2000
goto main

function _CheckInput(MaxTextSize)
   GotText$=""
   text$=text$+entry$()
   clear entry buffer
   `check for backspace
   if asc(right$(text$,1))=8
      if len(text$)>0 then text$=left$(text$,len(text$)-2)
   endif
   `check for return
   if asc(right$(text$,1))=13
      text$=left$(text$,len(text$)-1)
      if text$<>"" then GotText$=text$
   endif
   `check size of input
   if len(text$)>MaxTextSize then text$=left$(text$,MaxTextSize)
endfunction GotText$