ertlflorian1 Posted April 5, 2013 Share 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 Link to comment
DiSaMe Posted April 5, 2013 Share 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. Link to comment
Renkon Posted April 6, 2013 Share 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.. Link to comment
ertlflorian1 Posted April 6, 2013 Author Share 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? Link to comment
ixjf Posted April 6, 2013 Share Posted April 6, 2013 The 'break' keyword is useless in this case, 'return' keyword already stops the function. Link to comment
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