25 posts
Posted 06 February 2013 - 01:17 AM
Hi guys, im on a phn so grammar wont be best. Anyways, im having issues with my code… it seems that I continue to get the error <EOF> expexted at else.
print("Insert Password")
io.write("» ")
if read("*") == "test" then
print("Password ACCEPTED")
sleep(2)
end
else
print("DOH")
end
end
Please help!
497 posts
Location
The Big Apple, NY
Posted 06 February 2013 - 01:18 AM
Delete the end right before the else…not needed
2088 posts
Location
South Africa
Posted 06 February 2013 - 02:44 AM
To extend on what Skullblade said…
A full if / function / loop block needs to end with only
one end.
if ... then
..
elseif .. then
else
end
You can also use elseif's for more conditions.
1852 posts
Location
Sweden
Posted 06 February 2013 - 07:42 AM
If you still having problems then here are the code:
print("Insert Password")
io.write("» ")
if read("*") == "test" then
print("Password ACCEPTED")
sleep(2)
else
print("DOH")
end
You could also do this to improve the code:
Spoiler
while true do -- So it's looping until it's correct
term.clear() --This Clears The Screen
term.setCursorPos(1,1) -- This Sets The Position to X:1 Y:1
print("Insert Password")
io.write("» ")
if read("*") == "test" then
print("Password ACCEPTED")
sleep(2)
return -- Here It Breaks From The Loop
else
print("DOH")
sleep(2)
end -- Ends The "while true do"
end --Ends The "if"
--[[
If It Had Been An Function You would have needed
another end ofcourse,
I hope any of this helped you! =)
]]--
25 posts
Posted 06 February 2013 - 02:52 PM
None of the above worked. Also, I'm doing it on notepad++ and sigmascript. Could this be part of the issue?
1054 posts
Posted 06 February 2013 - 02:55 PM
None of the above worked. Also, I'm doing it on notepad++ and sigmascript. Could this be part of the issue?
Define "not working". I don't see anything wrong with Hellkid98's snippet.
144 posts
Location
Wellington, New Zealand
Posted 06 February 2013 - 04:34 PM
Tested Hellkid98's snippet on ccemu. Nothing wrong. Something has probably gone wrong while you were copying/pasting. You should look over the code you have.
2005 posts
Posted 06 February 2013 - 11:01 PM
To reiterate a point, when you have modified your code and it is still not performing as desired, you must post the current code and a precise description of the undesired behavior (including complete error message or other output), in order to obtain further help to be relevant to your situation.