Computer Science Canada Password and Usernames loggin |
Author: | Darkshining [ Mon Sep 19, 2005 8:52 pm ] |
Post subject: | Password and Usernames loggin |
Hi, i am a first time poster on this forum, i searched up the forum for this but none of them actually explained what i want to do: I've wrote a program that you can set a password and it gives you 4 attemps before locking your account down. i want to achieve: 1. make password into *s 2. make a database that can save people's usernames and bring them up on command with matching passwords var VAR_PWD : string var VAR_PASSWD : string :="88888" %User defined Password var d : int :=4 %how many times do you want the user to attempt? for i: 1 .. d put "Please enter your password." get VAR_PWD if VAR_PWD not= VAR_PASSWD then put "Wrong Password, ", i, " Attempt." if i = d then put "Your Account is locked for safety purposes." end if else put "Thank you for logging in." exit end if end for |
Author: | Tony [ Mon Sep 19, 2005 9:18 pm ] |
Post subject: | |
for *s, View.Set("noecho") and use getch char in a loop. for a "database", just read/write to file. |
Author: | Darkshining [ Mon Sep 19, 2005 9:30 pm ] |
Post subject: | |
i started learning turing a week ago, so your answer doesn't really ring a bell to me. can you impliment the *s in my program so i can see what what mean? i know getch is getcharacter, but it only works with string (1), if i want the user to define a password, then i wouldn't know how many of them to use. |
Author: | Tony [ Mon Sep 19, 2005 9:36 pm ] | ||
Post subject: | |||
that's why I've said to use getch inside a loop. Get one character at a time until the user is done (return key?)
try to figure out what you can do with that c character ![]() |
Author: | Darkshining [ Tue Sep 20, 2005 10:32 am ] | ||
Post subject: | |||
that is the code, it uses ****, but the enter key does not work now, is there a way around it?
|
Author: | TokenHerbz [ Tue Sep 20, 2005 1:43 pm ] | ||||
Post subject: | |||||
Hi, i could be wrong BUT...
That is what you have, i think you need to EXIT that loop to move on, So, Try something along the lines of adding,
Try that, i didn't test it, but it might work Im sure theres other ways to do this, but fiddle with mine ![]() Bye, hope i helpd a bit also, you have getch then put inside that loop, i think you might want to STORE the letters then link them up later to make your password, cause i dont think your code will work on that aspect... |
Author: | [Gandalf] [ Tue Sep 20, 2005 4:14 pm ] | ||||
Post subject: | |||||
There are quite many solutions, you could (according to your example):
or
and more. |
Author: | Darkshining [ Tue Sep 20, 2005 5:51 pm ] |
Post subject: | |
i am so confused, can you please add it into my code instead of write the part because i don't know where to add it in. (i started a week ago) and also, if using getch, how do i piece the Characters together to form my predefined password? |
Author: | Cervantes [ Tue Sep 20, 2005 6:29 pm ] | ||
Post subject: | |||
Keep a running tally:
Insert the exit when statement just after your getch line. Don't use Input.KeyDown. getch can do this fine, and intermingling the two will just cause problems. |
Author: | Mr. T [ Tue Sep 20, 2005 6:32 pm ] |
Post subject: | Alex's Opinion |
Cervantes wrote: Don't use Input.KeyDown. getch can do this fine, and intermingling the two will just cause problems.
I've heard that before, but I've never understood why? |
Author: | Darkshining [ Tue Sep 20, 2005 7:20 pm ] | ||
Post subject: | |||
i am not sure if this is suppose to happen, it opens a window and it says waiting for input. but i can't type anything.
|
Author: | Cervantes [ Tue Sep 20, 2005 7:25 pm ] | ||
Post subject: | |||
It has to do with what catches what. So far as I have gone, there's only been one time when I've found it acceptable to use them at the same time. That is when looking for ctrl+arrow and ctrl+shift+arrow within the same loop. (This was when I was doing the textfield.) Try playing around with it. I think you'll find things will go arwy. If they don't, try changing the order of the getch & Input.KeyDown (which appears first in the loop). Post your findings. ![]() Here's a bad example:
It could just be me, but that seemed to always return false and a, no matter what I pressed. What's worse, I experienced an Internal Fatal Error. Mind you, that's problem a problem with WINE. In any case, there are places where you will get into trouble for combining these. Try to find a pattern and explain the reason! |
Author: | Cervantes [ Tue Sep 20, 2005 7:34 pm ] |
Post subject: | |
You're still using get. And you're using getch as well. Why? And why are you adding c to input? Judging by the initialization value of Input, it seems to be a code to output with every keystroke, rather than a variable to store the input with each keystroke. (The initialization value suggests one thing, the variable handle and the code suggest another thing.) |
Author: | Darkshining [ Tue Sep 20, 2005 7:37 pm ] | ||
Post subject: | |||
This is a working Password code. I wanted it to express the password as *s but instead it just shows nothing at all. But the good thing is, it works like this: press enter, type password, then press enter. try it, password is 55555. If someone can find the 2 problems i said above, then great! thank you
|
Author: | Cervantes [ Tue Sep 20, 2005 7:53 pm ] | ||
Post subject: | |||
Indenting your code is very helpful for reading it. Auto-indent by pressing F2. Still, you're collecting everything you getch into "input" but never using the "input" variable anywhere! You could just leave whatever you getch in 'c'. Also, it is a good idea to get away from using get. Try making this whole thing with getch, the way you originally planned it. Here's a start:
|
Author: | Darkshining [ Tue Sep 20, 2005 9:12 pm ] | ||
Post subject: | |||
Ok, This is it. Works, i am 99% sure it has no problems. Thank you all for your efforts!
|
Author: | Cervantes [ Wed Sep 21, 2005 3:05 pm ] |
Post subject: | |
Almost. What happens if you log in successfully on your first try? Or any try, for that matter? (Though if you successfully log in on your last try, there is no problem.) ![]() |
Author: | Darkshining [ Wed Sep 21, 2005 5:31 pm ] | ||
Post subject: | |||
I missed one word! lol
the exit. ![]() |
Author: | Cervantes [ Wed Sep 21, 2005 5:50 pm ] |
Post subject: | |
Good. ![]() Now, try using fonts! I believe there's a tutorial in the walkthrough, though I cannot guarentee quality... There's also the Turing Help Manual (F10). Start by looking at Font.New, then learn Font.Draw, and finally Font.Free. After that, use textfields! (Although there are probably lots of things to learn between now and when you use textfields. To pique your curiosity, though: Click here, and download the textfield.zip file. Run Ex Field.t. |