Re: Password prompt routine
- Posted by euman at bellsouth.net Aug 17, 2001
- 416 views
If you know the key values already which it sounds like you do, why couldnt you trap the key presses and process screen output based on the trapped key. I had a demo for this very thing somewhere, I went looking for it but it has misteriously been placed somewhere on my HD but because I have no method for nameing things it's lost at the moment.... hehe funny huh? Euman euman at bellsouth.net ----- Original Message ----- From: <freeplay at mailandnews.com> To: "EUforum" <EUforum at topica.com> Sent: Friday, August 17, 2001 18:00 Subject: Password prompt routine > > Hello again folks! > > Ok I've got a routine I've called "getpw". You give it a prompt string, it > displays this prompt and then accepts a line of input which is terminated > when you press return. The routine returns the typed line. When you type > a character it prints a single '*' character so you know you've typed the > character but has the nice effect that what you type is hidden from prying > eyes. Hence GET PassWord > > I detect the backspace key (ASCII code 8) and deal with it accordingly > (i.e. throw away the last character typed). I was hoping to print a > "backspace, space, backspace" sequence to rub out the last '*' character > but can't get this to work. Instead I'm currently printing a '#' character > to indicate that the last character has been "erased". If someone can help > me achieve the "backspace, space, backspace" effect I'm after I'd be very > grateful. > > Regards. > > FP. > > > function getpw(sequence prompt) > sequence pw > integer key > integer lenpw > > printf(1, "%s", {prompt}) > > pw = "" > > while 1 do > lenpw = length(pw) > > key = wait_key() > > if ( (key = 10) or (key = 13) ) then > if lenpw > 0 then > exit > end if > end if > > if ( (key = 8) or (key = 127) ) then > if (lenpw > 0) then > printf(1, "#", {}) > > if (lenpw = 1) then > pw = "" > else > pw = pw[2..lenpw] > end if > end if > end if > > if ( (key >= 32) and (key <= 126) ) > then > printf(1, "*", {}) > pw = append(pw, key) > end if > end while > > printf(1, "\n", {}) > > return(pw) > > end function > > > End of message. > > > > >