ZCCBJSB%EB0UB011.BITNET@cunyvm.cuny.edu (Josep Sau B.) (04/15/91)
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)