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

If...Then statement not detecting 'end'

Started by sk_2013, 30 November 2012 - 05:29 AM
sk_2013 #1
Posted 30 November 2012 - 06:29 AM
 repeat
  term.clear()
  term.setCursorPos( 1, 2)
  term.setTextColor(1)
  Status = redstone.getOutput("back")
  Status = tostring(Status)
  print("	 #-------------------------#")
  print("	 |	Server Power Grid	|")
  print("	 |	 Current Status:	 |")
  io.write("	 |		 ")
  if Status == "true" then
	Switch = false
	term.setTextColor(8192)
	io.write("Online		  ")
  elseif Status == "false" then
	Switch = true
	term.setTextColor(16384)
	io.write("Offline		 ")
  else
	Switch = false
	term.setTextColor(16)
	io.write("Error		   ")
	term.setTextColor(1)
  end
  term.setTextColor(1)
  print("|")
  print("	 |						 |")
  print("	 |	Change Power Mode?   |")
  print("	 |						 |")
  print("	 |						 |")
  print("	 #-------------------------#")
  term.setCursorPos( 18 , 8 )
  Change = io.read()
  if Change == "Yes" then
	redstone.setOutput("back", Switch)
	term.setTextColor(2048)
	term.setCursorPos( 13, 9 )
	print("Status Changed")
	break
  elseif Change == "No" then
	term.setTextColor(2048)
	term.setCursorPos( 16, 9 )
	print("Accepted")
	break
  else
	term.setTextColor(16)
	print("Error")
  end
  term.setCursorPos( 1, 1)
  os.sleep(2)
until Unchangablevariable == changed
repeat
  term.clear()
  term.setCursorPos(1,1)
  print("	 #---------------------#")
  print("	 |	  Open Door?	 |")
  print("	 |					 |")
  print("	 #---------------------#")
  term.setCursorPos(15, 3)
  Door = io.read()
  if Door == "No" then
    break
  end
	if Door == "Yes" then
		Attempts = 1
		until Attempts > 3 do
			term.setCursorPos(10,2)
			io.write("Password Required")
			term.setCursorPos(15,3)
			Password = io.read()
			if Password == "666" then
				redstone.setOutput("right", 1)
				os.sleep(10)
				redstone.setOutput("right", 0)
				break
			else
				term.setCursorPos(14,3)
				term.setTextColor(16)
				io.write("ERROR")
				os.sleep(1)
				term.setCursorPos(14,3)
				term.setTextColor(1)
				io.write("	")
				Attempts = Attempts + 1
			end
		end
   end
until Unchangablevariable == Changed
I'm very well aware I've broken a number of programming conventions, and this may be a pain to read.
Anyway, I'm getting the following error: bios:338:[string:"startup"]:66: 'end' expected (to close if on line 64)

Any help?
OmegaVest #2
Posted 30 November 2012 - 06:49 AM
You added an until line between an if and its end. You can't do that. And I don't know how you would fix it, but given you've written this, I'm betting you can figure it out.


EDIT: Actually, I did figure it out. Use while instead of until. Or a for loop.