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

Java exception throw

Started by RadimBur, 04 February 2015 - 08:09 PM
RadimBur #1
Posted 04 February 2015 - 09:09 PM
Hello everybody, where is a problem, please ? When I write a name and I click to Aplly it's writes "Jawa exception thrown"

sorry for my English


function createuser ()
		if register == 0 then
			newuser = ""
			newpass = ""
			newpas = ""
			end
		  
	term.setBackgroundColor(colors.blue)
	   term.setCursorPos(1,1)
	   print "			   "
	   paintutils.drawPixel(16, 1, colors.gray)
	local myWindow = window.create(term.current(),17,1,37,19)
	myWindow.setBackgroundColor(colors.white)
  
	myWindow.clear()
	myWindow.setCursorPos (2,3)
	term.setTextColor(colors.black)
	print "Create a new account"
	myWindow.setCursorPos(2, 5)
	print "User name:"
	myWindow.setCursorPos(2, 7)
	print " Password:"
	term.setBackgroundColor(colors.gray)
	term.setTextColor(colors.white)
	myWindow.setCursorPos(30, 16)
	print " Apply "
	term.setBackgroundColor(colors.lightGray)
	myWindow.setCursorPos(13, 5)
	print "			  "
	myWindow.setCursorPos(13, 5)
	print (newuser)
	myWindow.setCursorPos(13, 7)
	print "			  "
	myWindow.setCursorPos(13, 7)
	print (newpas)
  
	while true do
  local event, button, x, y = os.pullEvent("mouse_click")
  xy = x..","..y
  
		if x >= 29 and x <= 44 and y == 5 and button == 1 then
			term.setBackgroundColor(colors.gray)
			term.setCursorPos(29, 5)
			print "			  "
			term.setCursorPos(29, 5)
			newuser = read ()
			register = 1
			createuser ()
		elseif x >= 29 and x <= 44 and y == 7 and button == 1 then
			term.setBackgroundColor(colors.gray)
			term.setCursorPos(29, 7)
			print "			  "
			term.setCursorPos(29, 7)
			newpass= read ("@")
			newpas = "Password"
			register = 1
			createuser ()
			end
	if x >= 44 and x <= 50 and y == 16 and button == 1 then
		if not fs.exists ("/system/.ucet/"..newuser) then
			file = fs.open ("/system/.ucet/"..newuser.."/.data", "w")
			file.writeLine(newuser)
			file.writeLine(newpass)
			file.close ()
			print "Complete"
			createuser ()
			end
	elseif x >= 2 and x <= 10 and y == 3 and button == 1 then
	setupmenu ()
elseif x >= 2 and x <= 10 and y == 5 and button == 1 then
	password ()
	elseif x >= 2 and x <= 10 and y == 7 and button == 1 then
	logon ()
	elseif x >= 2 and x <= 10 and y == 9 and button == 1 then
	createuser ()
	elseif x >= 2 and x <= 10 and y == 11 and button == 1 then
	odhlasit ()
else
paintutils.drawLine(1, 1, 51, 1, colors.black)
paintutils.drawPixel (51,1, colors.red)
	term.setTextColor(colors.white)
	term.setCursorPos (51,1)
print "*"
	paintutils.drawPixel (50,1, colors.lightGray)
	term.setCursorPos (50,1)
	print "<"
	while true do
  local event, button, x, y = os.pullEvent("mouse_click")
  xy = x..","..y

  if x == 51 and y == 1 then
   plocha ()
  elseif x == 50 and y == 1 then
   account ()
		else
  createuser ()
   end
   end
end
end
end
createuser ()
Edited on 04 February 2015 - 08:40 PM
RadimBur #2
Posted 04 February 2015 - 10:01 PM
pastebin get VPzULJ7J test

This is file with code
Bomb Bloke #3
Posted 04 February 2015 - 11:13 PM
Did you also write a password? If not, "newpass" would be nil, and when you try to write that to disk it'll likely crash.

Speaking of which, you never set "register" to 0.
RadimBur #4
Posted 05 February 2015 - 09:39 AM
Fixed thanks :)/>