PDA

View Full Version : What did I do wrong??



abnrange
12-08-2007, 04:16 PM
I wanted to have multi passwords with different actions. When I add the 3rd password, nothing happens it does not check the nAttempt. No error.. here is the code, any help would be great. Thanks

sPassword = Dialog.PasswordInput("My App", "Please Enter Your Password:", MB_ICONQUESTION);
if sPassword ~="".. sPassword and sPassword ~="CANCEL" then
if sPassword == "pwd1" then
Button.SetVisible("Button1", true);
Button.SetVisible("Button2", true);
Button.SetVisible("Button3", true);
Button.SetVisible("Button4", true);
Button.SetVisible("Button5", true);
Button.SetVisible("Button6", true);
Button.SetVisible("Button7", true);
Image.SetVisible("Image2", true);
Image.SetVisible("Image3", true);
Image.SetVisible("Image4", true);
Image.SetVisible("Image10", true);
elseif sPassword == "pwd2" then
Button.SetVisible("Button1", false);
Button.SetVisible("Button2", false);
Button.SetVisible("Button3", true);
Button.SetVisible("Button4", false);
Button.SetVisible("Button5", false);
Button.SetVisible("Button6", false);
Button.SetVisible("Button7", false);
Image.SetVisible("Image2", false);
Image.SetVisible("Image3", false);
Image.SetVisible("Image4", false);
Image.SetVisible("Image10", false);

elseif sPassword == "pwd3" then
Button.SetVisible("Button1", false);
Button.SetVisible("Button2", true);
Button.SetVisible("Button3", true);
Button.SetVisible("Button4", true);
Button.SetVisible("Button5", false);
Button.SetVisible("Button6", true);
Button.SetVisible("Button7", false);
Image.SetVisible("Image2", false);
Image.SetVisible("Image3", false);
Image.SetVisible("Image4", false);
Image.SetVisible("Image10", false);

elseif sPassword ~= "pwd1".. sPassword ~= "pwd2" and sPassword ~= "pwd3" then
nAttempt = nAttempt+1;
Dialog.Message("Error", "Number of Attempts : "..""..nAttempt.." of 5 allowed", MB_OK, MB_ICONEXCLAMATION);
if nAttempt == 5 then
Application.Exit();
else
Page.Jump("Agree");
end
end

holtgrewe
12-08-2007, 05:32 PM
elseif sPassword ~= "pwd1".. sPassword ~= "pwd2" and sPassword ~= "pwd3" then

You have a typo in red - change to 'and'.

HTH

abnrange
12-08-2007, 05:37 PM
Got the typo, what do I use to seperate the passwords? I tried , ~= and , nothing works. What am I missing. Thanks for the quick reply.

holtgrewe
12-08-2007, 06:23 PM
You'll need to change your logic. If the password is correct,the logic will never reach the final else statement to the Page.Jump("Agree")

I won't embarrass myself by trying to code it. I'm sure you can code better than I can. LOL.

A quick test may be to place an 'end' after the password tests and start a new 'if' statment where you test the '~='


end
if sPassword ~= "pwd1" and sPassword ~= "pwd2" and sPassword ~= "pwd3" then
nAttempt = nAttempt+1;
Dialog.Message("Error", "Number of Attempts : "..""..nAttempt.." of 5 allowed", MB_OK, MB_ICONEXCLAMATION);
if nAttempt == 5 then
Application.Exit();
else
Page.Jump("Agree");
end
HTH

abnrange
12-08-2007, 06:48 PM
I see the logic, but can't make it work. Not sure what I 'm doing wrong!? I will keep trying. Thanks for the help...

Mina
12-11-2007, 08:54 AM
Hmm it would be easier if u replace

elseif sPassword ~= "pwd1".. sPassword ~= "pwd2" and sPassword ~= "pwd3" then

with simply


else

:)

abnrange
12-11-2007, 09:29 AM
I knew I was missing something... Thanks for the help!