This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kingofawesome13's profile picture

<eof> expected and end needed

Started by Kingofawesome13, 02 June 2014 - 01:00 AM
Kingofawesome13 #1
Posted 02 June 2014 - 03:00 AM
Title: <eof> expected and end needed

This really weird thing is happening to me and I don't know why.

ALSO: Yes, I did read the "Read This Post Before Asking Questions"

IMGUR ALBUM

Full program code(Any help debugging this code would be a huge help):


term.clear()
term.setCursorPos(2,1)
print("--WELCOME TO SiliCo (TM) TERMINAL VT5 USER INTERFACE--")
term.setCursorPos(2,3)
print("-CODE OPTIONS-")
term.setCursorPos(4,4)
print("[Open Door]		 1")
term.setCursorPos(4,5)
print("[Close Door]		2")
term.setCursorPos(4,6)
print("[Shutdown Terminal] 3")
term.setCursorPos(2,8)
write("[Code] ")
input = read()
if input == '1' then
redstone.setOutput("back", true)
print("[Door Opened")
sleep(1)
term.clear()
shell.run("startup")
elseif input == '2' then
redstone.setOutput("back", false)
print("Door Closed")
sleep(1)
term.clear()
shell.run("startup")
elseif input == '3' then
term.setCursorPos(2,11)
print("-TERMINAL SHUTDOWN REQUEST DETECTED-")
term.setCursorPos(2,13)
print("Are You Sure You Want To Shutdown This Terminal?")
term.setCursorPos(4,14)
print("[Yes] 4")
term.setCursorPos(4,15)
print("[No] 5")
term.setCursorPos(2,17)
write("[Code] ")
input = read()

if input == '4' then
  term.setCursorPos(2,25)
  print("-TERMINAL SHUTTING DOWN-")
  sleep(0.5)
  term.setCursorPos(2,27)
  print("-THANK YOU FOR CHOOSING SiliCo (TM)-")
  sleep(1)
  os.shutdown()
  end
  term.clear()
  shell.run("startup")
elseif input == '5' then
  term.setCursorPos(2,25)
  print("Shutdown Terminated")
  term.setCursorPos(2,27)
  print("Returning")
  sleep(2)
  term.clear()
  shell.run("startup")
else
  term.setCursorPos(2,25)
  print("Invalid Input")
  sleep(2)
  term.clear()
  shell.run("startup")
else
term.setCursorPos(2,25)
  print("Invalid Input")
  sleep(2)
  term.clear()
  shell.run("startup")

Thanks for your help in advance.
Whitecatblack #2
Posted 02 June 2014 - 03:26 AM
Kingofawesome13 said:
Title: <eof> expected and end needed
I believe the post you are referencing does in fact cover those errors…

Eof expected suggests you have too many (end)s.
End expected suggests you have too little (end)s.

Whitecatblack
Edited on 02 June 2014 - 01:27 AM
gezepi #3
Posted 02 June 2014 - 04:07 AM
if begins a block which must be closed with an end. So when you check what the user typed it would look like this

if input=='1' then
  --Do stuff
elseif input=='2' then
  --Do stuff
  --The rest of the checks...
end
Bomb Bloke #4
Posted 02 June 2014 - 04:17 AM
You'll find it much, much easier to keep track of where your "ends" should go if you use proper indentation.
Kingofawesome13 #5
Posted 02 June 2014 - 10:18 PM
Kingofawesome13 said:
Title: <eof> expected and end needed
I believe the post you are referencing does in fact cover those errors…

Eof expected suggests you have too many (end)s.
End expected suggests you have too little (end)s.

Whitecatblack

Might want to check out the third line of text in the topic.

"ALSO: Yes, I did read the "Read This Post Before Asking Questions"

if begins a block which must be closed with an end. So when you check what the user typed it would look like this

if input=='1' then
  --Do stuff
elseif input=='2' then
  --Do stuff
  --The rest of the checks...
end

ahah, that worked perfectly, thank you.