Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!know!news.cs.indiana.edu!rutgers!cmcl2!adm!news From: ZCCBJSB%EB0UB011.BITNET@cunyvm.cuny.edu (Josep Sau B.) Newsgroups: comp.lang.pascal Subject: Optimizing 'Dots qwill echo...' Message-ID: <26556@adm.brl.mil> Date: 15 Apr 91 12:22:50 GMT Sender: news@adm.brl.mil Lines: 45 What about this improvement that only requires one CHAR temporal variable: TYPE Pw = STRING(.15.); PROCEDURE GetPw (VAR InPw :Pw); CONST CR = CHR(13); BCK = CHR(8); VAR ch :CHAR; BEGIN (* GetPw *) writeln; write('Password (dots will echo): '); InPw := ''; REPEAT Read(KBD,ch); IF ch = BCK THEN BEGIN InPw := Copy(InPw,1,PRED(LENGTH(InPw)); (* :: Copy_But_Last_Char *) write(ch); END; ELSE IF ch <> CR THEN BEGIN InPw := InPw + ch; write('.'); END; UNTIL ch = CR; END; (* GetPw *) Note: Clrscr may not work on generic MS-DOS machines (not true-blue ones). A really portable alternative may be: FOR x := 1 TO 25 DO writeln; but this leave the cursor at the 25th row... --Josep Sau 'Every science needs the right words to be expressed the right way' Raimundus Lulius (Catalan philosopher)