Re: get_key() with backspace
- Posted by Irv Mullins <irv at ELLIJAY.COM> Mar 28, 1998
- 991 views
(Oops, I sent this to Pete by mistake -- sorry) At 11:30 PM 3/27/98 -0800, you wrote: >Kevin Sieger wrote: >> >> Yes, there is an easier way to input a string, but the use of the >> get_key allows me to implement real time in a multi-user rpg I'm >> developing. Ok, here are some answers: 1. puts(1,14), as someone suggested, does not work 2. the following code does: ---------------------------------------------------------------------------- --------- -- getstr() routine to implement b/s char while using get_key() ---------------------------------------------------------------------------- --------- sequence test function getstr() object s sequence buffer buffer = {} while 1 do s = get_key() if s > -1 then if s = 8 then if length(buffer) > 0 then buffer = buffer[1..length(buffer)-1] -- clip last char puts(1,13) -- move to start of line puts(1,buffer & ' ') -- overlay last char with a space puts(1,13) -- move to start of line puts(1,buffer) -- put the updated string end if -- also puts cursor in right place elsif s = 13 then -- exit on c/r puts(1,"\n") exit else puts(1,s) -- other chars just accumulate buffer = buffer & s end if end if end while return buffer end function test = getstr() puts(1,test) ---------------------------------------------------------- --Visit my Euphoria programming web site:-- --http://www.mindspring.com/~mountains -- ----------------------------------------------------------