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

Program appears to freeze on run

Started by DragonZero, 11 September 2016 - 03:13 AM
DragonZero #1
Posted 11 September 2016 - 05:13 AM
When I run this program, the computer appears to lock up. Ctrl + T and Enter both fail to end the program (ctrl + r works, though), and no text appears on the monitor.

monitor=peripheral.wrap("monitor_0")
monitor.setTextScale(5)
function diplayTime()
  local timeRaw = 0
  local timeSec = 0
  local timeMin = 0
  local timeHrr = 0
  while true do
	monitor.clear()
	monitor.setCursorPos(1,4)
	monitor.write(timeRaw)
	os.sleep(1)
	timeRaw = timeRaw + 1
  end
end  
function breakLoop()
  while true do
	local event, par1 = os.pullEvent("key")
	if par1 == 28 then
	  print("Ending Program.")
	  break
	end
  end
end
parallel.waitForAny(displayTime,breakLoop)

Bomb Bloke #2
Posted 11 September 2016 - 05:55 AM
The only obvious problem I can see is the "diplayTime" typo, though I really would expect that to generate an error - are you sure this is the actual code you're running?
DragonZero #3
Posted 11 September 2016 - 03:26 PM
The only obvious problem I can see is the "diplayTime" typo, though I really would expect that to generate an error - are you sure this is the actual code you're running?
Fixing the typo seems to have fixed the code. I don't know why it didn't throw error, unless there was another function somewhere called diplayTime, but this was the only program I had written on this computer. Thanks for the help.