Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 password
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
droe




PostPosted: 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
Sponsor
sponsor
DemonWasp




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: