Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!haven!umbc3.umbc.edu!marmaduke.acslab.umbc.edu!cs202216 From: cs202216@marmaduke.acslab.umbc.edu (cs202216) Newsgroups: comp.lang.pascal Subject: Re: "Dots will echo:" for passwords... Message-ID: <1991Apr10.140340.7287@umbc3.umbc.edu> Date: 10 Apr 91 14:03:40 GMT References: <40822@netnews.upenn.edu> Sender: newspost@umbc3.umbc.edu (News posting account) Distribution: na Organization: University of Maryland Baltimore County, Academic Computing Services Lines: 83 In article <40822@netnews.upenn.edu> garay@hyper.lap.upenn.edu (John Garay) writes: > >I'm interested in a procedure in TP which will echo dots to the screen instead >of the actual keys pressed. In other words, one of the ol' > 'Please type in password (dots will echo):' >types of things. The form I have now (w/ the password broadcasted on the >screen is: clrscr; > writeln ('Please Type Password:'); > readln (password); > >I figure somewhere between the writeln and the readln there's got to be a way >to make dots echo instead of the (secret) password. Any ideas, anyone? >A little background: IBM TP3.01 (WAIT! I'm interested in ideas with any >TP version!). Thanks much for the help.... >****************************************************************************** > > John Garay e-mail : garay@hyper.lap.upenn.edu > Office phone : (215) 898-1954 > Home Phone : (215) 382-4102 > Donations : 4034 Walnut, Philly, PA 19104 > >"Change the Way People think, and things will Never be the Same." S. Biko > >****************************************************************************** > > To do this, you'll have to write a procedure to replace the readln procedure. example: Procedure GetPassword(var s : string); const bs = #8; cr = #13; esc = #27; bell = #7; var ch : char; begin s:=''; repeat if keypressed then begin ch:=readkey; case ch of bs : begin if length(s) > 0 then begin delete(s,length(s),1); write(bs+' '+bs); end else write(bell); end; cr : begin end; esc : begin { If escape is pressed, clear the input } while length(s) > 0 do begin write(bs+' '+bs); delete(s,length(s),1); end; end; else begin s:=s+ch; write('.'); end; end; until ch = cr; writeln; end; Hope this helps. Matt Gove Internet: cs202216@umbc5.umbc.edu