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

Problem:program don't work "end" expected (solved)

Started by CreeKsx3, 31 May 2013 - 08:50 AM
CreeKsx3 #1
Posted 31 May 2013 - 10:50 AM
hello everyone i have a problem -.-
i sit on a program to run games for my OS called Steam (i will change the name) but if i run the program 3 times then it doesent work anymore the erro says: Line 86 ['end' expected (to close 'while' at line 74)] i do what the erro says and then a new error apears it says: Line 87['<eof>' expected] i really don't now how to fix it becouse i have exact the same code in an other program only that i have add a funktion to display a topBar
Here is the Code :
Spoiler
--Steam
slc = 0
backColor = colors.lightGray
term.setBackgroundColor(backColor)
term.clear()
--###############################################
function topBar()
  term.setCursorPos(1,1)
  term.setTextColor(colors.white)
  term.setBackgroundColor(colors.gray)
  print("|Steam|Display|Games|Help|						")
  term.setCursorPos(51,1)
  term.setBackgroundColor(colors.red)
  print("X")
end
--###############################################
function topBar2()
  term.setCursorPos(1,2)
  term.setTextColor(colors.white)
  term.setBackgroundColor(colors.gray)
  print("<< >> |SHOP|Libary|")
  term.setCursorPos(40,2)
  term.setBackgroundColor(colors.gray)
  print("|   BIG   |")
end
--###############################################
function topBar3()
  term.setCursorPos(1,3)
  term.setTextColor(colors.white)
  term.setBackgroundColor(colors.gray)
  print("Search			|AllGames|	 View")
  term.etCursorPos(40,3)
  term.setBackgroundColor(colors.gray)
  print("| Pictures|")
end
--################################################
function titleBar()
  term.setCursorPos(1,19)
  term.setTextColor(colors.white)
  term.setBackgroundColor(colors.green)
  print(" Start ")
  term.setBackgroundColor(colors.blue)
  print("					   ")
end
--###############################################
function drawBackground()
  term.setBackgroundColor(backColor)
  term.clear()
  topBar()
  topBar2()
  topBar3()
  titleBar()
end
--################################################
function drawMenu1()

term.setCursorPos(1,16)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
write("Help	  ")

term.setCursorPos(1,17)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
write("Reboot	")

term.setCursorPos(1,18)
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
write("Shutdown  ")
end
--################################################
drawBackground()
while true do
local event, button, X, Y = os.pullEventRaw()
  if slc == 0 then
	if event == "mouse_click" then
	  if X >=1 and X <=7 and Y==19 and button ==1 then
	   drawMenu1()
	   end
	  slc = 1
		else
		drawBackground()
	  end
	end
   elseif slc == 1 then
	 if X >=1 and X <=11 and button == 1 and Y== 18 then slc = 0
	   os.shutdown()
	   elseif X>=1 and X<=11 and Y==17 and button ==1 then slc = 0
	   os.reboot()
	   elseif X>=1 and X<=11 and Y==16 and button ==1 then slc = 0
	   shell.run("/md7/main/help")
	   else
	   slc = 0
	   drawBackground()
	 end
  end
end  

sorry for my bad English i'm from germany
please help
W00dyR #2
Posted 31 May 2013 - 10:56 AM
You have an "end" to much in there.

At the part where it sais

if event == "mouse_click" then

You ended it twice, so it ended the

if slc == 0 then

loop as well.

Try removing that end and I think it should work fine :P/>
Spongy141 #3
Posted 31 May 2013 - 10:57 AM
after you put
 DRAWMENU() 
YOU PUT A EXTRA END, ALSO MY PHONE IS STUCK ON CAP LOCK
CreeKsx3 #4
Posted 31 May 2013 - 11:44 AM
thanks for the quick help it works now