Password programming question
staticattic
Posts: 200
I made a keypad that pops up on the TP when a user tries to look at a particular source. I created an array that can only hold 4 digits. Everything works great except for a bug I have found. When the user presses the "confirm" button, if the 4 numbers are correct, the series of events happens that allows that particular source to be displayed. However, if they press the "back" key, once they go all the way around, all 4 digits will re-display. I have tried CLEAR_BUFFER and SET_LENGTH_STRING to 0 but neither work. What am I doing wrong? Something else, when the user hits "confirm", the keypad disappears and they can continue on with business. If however, they once again open the keypad, the display comes blank, the length of the array shows 0, but one press of the backspace key will being up all 4 numbers again. After that all they need to do is press "confirm" and they are in.
0
Comments
This is the keypad "Backspace" key:
That is the part I think I have wrong. If they input 4 digits for example, pressing the backspace key will back up one digit at a time. When they press the backspace key a fifth time, all 4 digits will re-appear and the string will again be four digits long.
Also, anywhere you have CLEAR_BUFFER, substitute it with cKeyDigits = '' and see if that helps.
I suggest you use the built in password keypad. It does all the backspace/clear work for you. Once you get the data back from the TP, then check in your list to see if the password is good.
"'@PKP-<initial text>;<prompt text>'"
That too works nicely. I was thinking the same thing, but didn't know the command for it and figured he'd want to use his keypad for whatever reason.
Thanks for pointing that out Jeff!
IF Password 2 = CORRECT
{
do this
}
Thanks for all the replies.
As far as i can remember CLEAR_BUFFER doesn't actually clear the buffer, it just sets the index back to 0 (have to open my laptop with Netlinx Studio to double check)
It sets the length to zero; the data is still there. In these kinds of cases, I repopulate the string with nulls for the entire length, then use clear_buffer.