Newsgroups: comp.lang.pascal
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!news.cs.indiana.edu!ux1.cso.uiuc.edu!uxa.cso.uiuc.edu!amb43790
From: amb43790@uxa.cso.uiuc.edu (Anthony M Brummett)
Subject: Re: "Dots will echo: " for passwords...
Message-ID: <1991Apr11.041319.27294@ux1.cso.uiuc.edu>
Sender: usenet@ux1.cso.uiuc.edu (News)
Organization: University of Illinois at Urbana
References: <40822@netnews.upenn.edu>
Distribution: na
Date: Thu, 11 Apr 1991 04:13:19 GMT
Lines: 45

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

>******************************************************************************

The way I've done it is to rewrite the readln procedure:
  (* ReadSecret is used in the same context as ReadLn except it returns only
     one string *)
  procedure ReadSecret(var s:string);
    var c:char;
    begin
      s:='';
      repeat
        c:=ReadKey;
        if c<>#13 then 
          s:=s+c;
      until c=#13;
    end;{ReadSecret}

This, of course, is only a bare bones routine and does not detect keys like   
backspace, but should get the job done.

Antoine---------------------------amb43790@uxa.cso.uiuc.edu
	
