ertlflorian1 Posted April 5, 2013 Posted April 5, 2013 why it dont work? function checkifcorrectpw (pw) for i = 32, 255, 1 do if i < 49 or i > 57 and i < 65 or i > 95 and i < 97 or i > 122 then if string.find (pw, string.char (i), 1, true) then break return true elseif i == 255 and not string.find (pw, string.char (i), 1, true) then return false end end end end
DiSaMe Posted April 5, 2013 Posted April 5, 2013 'break' keyword escapes the loop at the point it's reached, preventing the code execution from reaching the 'return true' line.
Renkon Posted April 6, 2013 Posted April 6, 2013 In other words you just have to swap and flip break with return true or simply remove 'break' since its not necessary due to the return..
ertlflorian1 Posted April 6, 2013 Author Posted April 6, 2013 function checkifcorrectpw (pw) for i = 32, 255, 1 do if i < 49 or i > 57 and i < 65 or i > 95 and i < 97 or i > 122 then if string.find (pw, string.char (i), 1, true) then return true break elseif i == 255 and not string.find (pw, string.char (i), 1, true) then return false end end end end Dont work error: Loaddin script failed ... end expected ( to close if at 6) near break?
ixjf Posted April 6, 2013 Posted April 6, 2013 The 'break' keyword is useless in this case, 'return' keyword already stops the function.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now