TURBO PASCAL |
Новости
|
38: How can I read input without echoing to the screen?A: It is fairly simple. Study this example source code, with the manual, if need be. uses Crt; var password : string; {} (* Read without echoing *) procedure GETPASS (var s : string); var key : integer; ch : char; begin s := ''; repeat ch := ReadKey; key := ord (ch); case key of 0 : ch := ReadKey; (* Discard two-character keys, like F1 *) 13 : exit; (* Enter has been pressed *) 1..12,13..31,255 :; (* Discard the special characters *) else s := s + ch; end; until false; end; (* getpass *) {} (* The main program *) begin write ('Password: '); GETPASS (password); writeln; writeln (password); end. {} If you wish to be able to edit the input stream, like having the BackSpace functional, that is more complicated, and is left as an exercise after these basics. A hint: 8 : Delete (s, Length(s), 1); There is another approach to this problem pointed out by Colin Lamond colin@sound.demon.co.uk. Quite innovative in its simplicity once one comes to think of it. "Set the textcolor, and the textbackground to the same color, and so the typed text can not be seen on the screen." |
(с)Все права защищены По всем интересующим вопросам прошу писать на электронный адрес |