Problems with everything within a loop
Started by Hydrotronics, Nov 07 2015 11:34 PM
9 replies to this topic
#1
Posted 07 November 2015 - 11:34 PM
Pastebin: http://pastebin.com/E2qm6s5r
So, i am making myself an OS and i have run into a problem here:
whenever I run this program, it wants an end on line 32, but when i place an end there, it says "eof expected" on line 33! and that's an elseif statement! This is really aggrovating me and i just cannot get my head around it!
Please Explain why it is doing this!
Many Thanks, Hydro
So, i am making myself an OS and i have run into a problem here:
whenever I run this program, it wants an end on line 32, but when i place an end there, it says "eof expected" on line 33! and that's an elseif statement! This is really aggrovating me and i just cannot get my head around it!
Please Explain why it is doing this!
Many Thanks, Hydro
#2
Posted 07 November 2015 - 11:49 PM
I went through your code, properly indented it, and added comments where I know something is wrong. I don't know how you intend / intended to nest the various if/elseif statements, so you'll have to deal with this yourself.
Spoiler
#3
Posted 07 November 2015 - 11:52 PM
elseif act as an end for the prior if
remove the ends on lines 31,39,55
edit:
'd
remove the ends on lines 31,39,55
edit:
Edited by Lupus590, 07 November 2015 - 11:53 PM.
#4
Posted 07 November 2015 - 11:58 PM
Lupus590, on 07 November 2015 - 11:52 PM, said:
elseif act as an end for the prior if
No, it doesn't. You still need the end, but you don't need an end for each if / elseif / else. You need 1 end per conditional.
#6
Posted 08 November 2015 - 12:04 AM
There's a problem at the bottom, but I'm not exactly sure what you want it to do. I've indented it properly (PLEASE indent properly, it makes finding these problems so much easier).
sid = 0
function clear()
term.clear()
term.setCursorPos(1,1)
end
function menu(id, text)
if sid == id then
write"> "
else
write"| "
end
print(text)
end
while true do
clear()
menu(0, "Desktop")
menu(1, "Create/Edit Program")
menu(2, "Console")
menu(3, "Shutdown")
event, key = os.pullEvent("key")
if key == 200 then
print(sid)
if sid > 0 then
sid = sid - 1
else
sid = sid + 3
end
elseif key == 208 then
print(sid)
if sid < 3 then
sid = sid + 1
else
sid = sid - 3
end
elseif key == 28 then
if sid == 0 then
break
end
shell.run(".desktop")
elseif sid == 1 then
term.clear()
term.setCursorPos(1,1)
print"Enter Name Of File:"
write""
input = read()
shell.run("edit "..input)
elseif sid == 2 then
break
end
shell.run(".Console")
--#NO IF STATEMENT OPEN FOR THIS ELSEIF
elseif sid == 3 then
term.clear()
term.setCursorPos(10,9)
print"Shutting Down..."
sleep(1)
os.shutdown()
end
end
Edited by KingofGamesYami, 08 November 2015 - 12:05 AM.
#8
Posted 08 November 2015 - 12:20 AM
Spoiler
#9
Posted 08 November 2015 - 12:24 AM
Thank you! you were correct with the breaks, I am new to those. And also i did need the 3rd end, to clsoe the while statement all together
#10
Posted 08 November 2015 - 12:41 AM
KingofGamesYami, on 07 November 2015 - 11:58 PM, said:
Lupus590, on 07 November 2015 - 11:52 PM, said:
elseif act as an end for the prior if
No, it doesn't. You still need the end, but you don't need an end for each if / elseif / else. You need 1 end per conditional.
that's what I meant, sorry if I wasn't clear
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











