password
Author |
Message |
droe
|
Posted: Fri Mar 27, 2009 9:47 am Post subject: password |
|
|
you know when you type in a password for something and the password is shown as asteriks or something? how do you do that in turing? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
DemonWasp
|
Posted: Fri Mar 27, 2009 10:18 am Post subject: RE:password |
|
|
If you're using the GUI module, you can use GUI.SetEchoChar
If you're trying to do this with get, you can't. There's simply no way to tell it to do so; if you wanted, you could use this though:
Turing: |
fcn getPassword () : string
View.Set ("noecho")
var password : string := ""
var ch : char
loop
cls
Text.Locate (1, 1)
put "Enter Password: ", repeat ("*", length (password )) ..
ch := getchar ()
%put ord ( ch )
if (ord (ch ) = 8) then % Backspace = 8
if (length (password ) > 0) then
password := password (1 .. * - 1)
end if
elsif (ord (ch ) = 13 or ord (ch ) = 10) then % Return = 10 or 13 depending...
put ""
exit
elsif (ord (ch ) < 128 and ord (ch ) > 32) then % Printable character
if (length (password ) < 255) then
password + = ch
end if
end if
end loop
View.Set ("echo")
result password
end getPassword
var pwd : string
pwd := getPassword ()
put "password was entered as '"+pwd+ "'"
|
Basically, that tells Turing not to print your input to the screen ("noecho") then does the input-getting manually (adding to the "password" string, or removing characters if you hit backspace). No guarantees it's perfect, though. |
|
|
|
|
 |
|
|