Re: Backspace doesn't work in 4.1.0 programs?
- Posted by ChrisB (moderator) May 06, 2022
- 1839 views
Hi
Sorry, I should have been more specific - prompt_string() doesn't work because of the windows console in modern windows PC and eu. Annoying I know, I had the same problem on linux, so essentially wrote my own. It does mean you have to keep tighter control over what the screen is displaying though.
add this code onto the end (remove the other entry tests)
--------------------------------------------------------------------------------------------------------------------- global procedure printat(sequence coords, sequence text) --displays text at a position --------------------------------------------------------------------------------------------------------------------- position(coords[1],coords[2]) puts(1,text) end procedure --clear_screen() position(10,1) puts(1, "Enter string : ") sequence str = "" while 1 do printat({10, length("Enter string : ")}, str & " ") position(10, length("Enter string : " & str)) c = wait_key_nn() if c = bksp then if length(str) > 1 then str = str[1..length(str) - 1] end if else str = str & c --note - no checking for valid keys! end if if c = 13 then exit end if end while puts(1, "\n" & str & "\n") --need to do some tidying up, but thats the principle