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

<eof>

Started by icecube45, 23 November 2012 - 10:22 AM
icecube45 #1
Posted 23 November 2012 - 11:22 AM
Hello, my code is as follows

user = "icecube45"
user1 = "sun1raven"
user2 = "AdmKennedy"
password = "cubeice45"
password1 = "tomcat5"
password2 = "flyer42"
function menu()
term.clear()
term.setCursorPos(1,1)
print("Control Panel V1.0")
print("1: Toggle Dungeon")
print("2: Toggle Quarry")
print("3: Toggle Logo")
print("4: Status Report")
print("5: Log Out")
print("What Would You Like To Do?")
input = read()
if input == "1" or input == "2" or input == "3" or input == "4" then
  print("Under Construction")
  os.sleep(2)
  return menu()
   elseif input == "5" then
    print("Thank You for Using The Control Panel")
    os.sleep(2)
    os.rebbot()
   end
end
print("FactoryOS V2.0")
print("Choose A User:")
usercheck = read()
if usercheck == user or usercheck == user1 or usercheck == user2 then
term.clear()
term.setCursorPos(1,1)
print(usercheck.."'s Password:")
passcheck = read()
if passcheck == password or passcheck == password1 or passcheck == password2 then
  term.clear()
  term.setCursorPos(1,1)
  menu()
  end
  else
   print("Invalid Password")
   os.reboot()
   end
  end
else
    print("Invalid User")
    os.reboot()
    end
end
 

It says <eof> at line 47

I can't figure out what this means!
OmegaVest #2
Posted 23 November 2012 - 11:25 AM
You have an extra end somewhere. Specifically at line 26. With an if block, it's

if
-code-
end

if
-code-
elseif
-code-
end

or

if
-code-
elseif
-code-
else
-code-
end

If you nest an if, you don't need to use elseif to start the nest. Like so:

if
-code-
   if
   -code-
   end
elseif
-code
   if
   -code-
   else
   -code-
   end
end


But you do not need to use an end until ALL if, elseifs and elses have been completed in an if block.
icecube45 #3
Posted 23 November 2012 - 11:31 AM
Thanks!
This will help me alot in future coding!

print("-icecube45")
Dlcruz129 #4
Posted 24 November 2012 - 12:43 PM
You realize when you logout, you used os.rebbot(). That should have returned an error.
cmurtheepic #5
Posted 24 November 2012 - 03:13 PM
im working on fixing it at the moment ;)/>/>
cmurtheepic #6
Posted 24 November 2012 - 03:24 PM
the problem is you cant have that many else's in a program a else is basically used for like else
printer "error"
sleep(1)
os.shutdown or end

not to specify what it should say if it don't equal he if statement
here
is the fixed code:

user = "icecube45"
user1 = "sun1raven"
user2 = "AdmKennedy"
password = "cubeice45"
password1 = "tomcat5"
password2 = "flyer42"
function menu()
term.clear()
term.setCursorPos(1,1)
print("Control Panel V1.0")
print("1: Toggle Dungeon")
print("2: Toggle Quarry")
print("3: Toggle Logo")
print("4: Status Report")
print("5: Log Out")
print("What Would You Like To Do?")
input = read()
if input == "1" or input == "2" or input == "3" or input == "4" then
  print("Under Construction")
  os.sleep(2)
  return menu()
   elseif input == "5" then
    print("Thank You for Using The Control Panel")
    os.sleep(2)
    os.rebbot()
   end
end
print("FactoryOS V2.0")
print("Choose A User:")
usercheck = read()
if usercheck == user or usercheck == user1 or usercheck == user2 then
term.clear()
term.setCursorPos(1,1)
  elseif usercheck ~= user or usercheck ~= user1 or usercheck ~= user2 then
  print "Invalid Username"
  sleep(1)
  os.reboot()
  end
print(usercheck.."'s Password:")
passcheck = read()
if passcheck == password or passcheck == password1 or passcheck == password2 then
  term.clear()
  term.setCursorPos(1,1)
  menu()
  elseif passcheck ~= password or passcheck ~= password1 or passccheck ~= password2 then
   print("Invalid Password")
   sleep(1)
   os.reboot()
  end
there you your welcome ;)/>/>