Jump to content




Process not being detected


  • You cannot reply to this topic
3 replies to this topic

#1 cdel

  • Banned
  • 496 posts
  • LocationMelbourne, Australia

Posted 06 March 2015 - 01:11 PM

I am creating a small multitasking system, I am clearly creating the process with the new() function, however when I use the run() function it claims that the process doesn't exist. My code is as follows:
local tArgs = {...}
local process = { }
local proc = { }
local er = function(text)
  error(shell.getRunningProgram()..": "..text, 0)
end
local new = function(name, func, dVa)
  if type(name) == "string" then
    if type(func) == "function" then
	  if type(dVa) == "table" then
	    process[name] = { }
	    process[name]["Pr"] = coroutine.create(func)
	    process[name]["Di"] = window.create(term.native(), dVa[1], dVa[2], dVa[3], dVa[4], dVa[5])
	    table.insert(proc, name)
	  end
    else
	  er("Function expected")
    end
  else
    er("String expected")
  end
end
local run = function(name)
  if type(name) == "string" then
    if process[name] then
	  if coroutine.status(process[name]["Pr"]) == "suspended" then
	    coroutine.resume(process[name]["Pr"])
	    term = process[name]["Di"]
	  else
	    er("Process is "..coroutine.status(process[name]["Pr"])) 
	  end
    else
	  er("Process doesn't exist")
    end
  else
    er("String expected")
  end
end
local hello = function()
  shell.run("hello")
end
new("hi", hello)
run("hi")


#2 GopherAtl

  • Members
  • 888 posts

Posted 06 March 2015 - 01:19 PM

you forgot to pass new a dVa argument, and new doesn't display an error when that inner-most "if type(dVa)=="table" conditional fails.

Edited by GopherAtl, 06 March 2015 - 01:23 PM.


#3 CoderPuppy

  • Members
  • 121 posts

Posted 06 March 2015 - 01:21 PM

You're not passing a third argument to new.
Edit: ninja'd

Edited by CoderPuppy, 06 March 2015 - 01:22 PM.


#4 cdel

  • Banned
  • 496 posts
  • LocationMelbourne, Australia

Posted 06 March 2015 - 01:27 PM

oh right, I forgot to add data for a new feature... *facepalm*. Thanks :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users