Computer Science Canada

Password program help

Author:  con.focus [ Sat Jan 08, 2005 4:36 pm ]
Post subject:  Password program help

K im make a pass word file that covers the password over with stars
the program has a big problem

which is if an incorect password is enter first it will and then the corect password is entered it does n't reconize it

this does not happen when the correct pwd is enter the first time
code:
var key : string (1)
var password : string := ""
var counter : int
counter := 0
loop
    loop
        getch (key)
        exit when ord (key) = 10
        put "*" ..
        password += key
    end loop
    put ""
    counter += +1
    if counter = 3 then
        quit
    elsif password = "sze" then
        exit
    end if
end loop
put ""
put "Welcome to Scotia Bank"


can ne 1 help

Author:  Andy [ Sat Jan 08, 2005 4:44 pm ]
Post subject: 

dont do it that way
just use setscreen("noecho")
and then everytime a key is pressed, output a "*"

Author:  con.focus [ Sat Jan 08, 2005 4:49 pm ]
Post subject: 

wut exactly do u mean

Author:  Andy [ Sat Jan 08, 2005 4:54 pm ]
Post subject: 

make a new program, and at the very top put setscreen("noecho")
and then write a program that gets someones name, run it and u'llsee what i mean

Author:  con.focus [ Sat Jan 08, 2005 4:57 pm ]
Post subject: 

i did that but the only thing it write at is enter wont lets u inout other chars


btw is there a command that will resart ur program

Author:  Andy [ Sat Jan 08, 2005 5:05 pm ]
Post subject: 

err u can put it in a loop.. or u can make it an exe and use Sys.Execute

and btw... that program i told you to write dos input letters, you just cant see it being inputted which is the whole point of hiding it.. ah wells, here is a password program i wrote a while back

code:

fcn getpass : string
    var pass := ""
    var charc : string (1)
    loop
        getch (charc)
        exit when ord (charc) = 10
        if ord (charc) = 8 and length (pass) not= 0 then
            locate (whatrow, whatcol - 1)
            put " " ..
            locate (whatrow, whatcol - 1)
            pass := pass (1 .. length (pass) - 1)
        elsif ord (charc) not= 8 then
            pass := pass + charc
            put "*" ..
        end if
    end loop
    put ""
    result pass
end getpass

put getpass

Author:  con.focus [ Sat Jan 08, 2005 5:27 pm ]
Post subject: 

yo thx ne way but i just realized that this line
code:
password+= key

is acting like this one
code:
counter += +1

all i needed to do was reset the variable at the end of the loop


: