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")
Process not being detected
Started by cdel, Mar 06 2015 01:11 PM
3 replies to this topic
#1
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:
#2
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
Posted 06 March 2015 - 01:21 PM
You're not passing a third argument to new.
Edit: ninja'd
Edit: ninja'd
Edited by CoderPuppy, 06 March 2015 - 01:22 PM.
#4
Posted 06 March 2015 - 01:27 PM
oh right, I forgot to add data for a new feature... *facepalm*. Thanks
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











