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

OS run feature help

Started by Boss Nomad, 29 December 2012 - 01:59 AM
Boss Nomad #1
Posted 29 December 2012 - 02:59 AM
I have just made OS for my use only. It has "Run program" feature.

Problem:

When i run program that has error with this feature, it will crash OS. Is there way to run startup always when program closes?

I will not give code, because i have meant it only for my use. If you dont know how to solve this without the code then you cant help me.
grabie2 #2
Posted 29 December 2012 - 03:19 AM
Look at that: http://www.lua.org/manual/5.1/manual.html#pdf-pcall
ChunLing #3
Posted 29 December 2012 - 03:20 AM
You can always pcall a loadstring.
Boss Nomad #4
Posted 29 December 2012 - 07:40 AM
There wasnt alot info about it, can someone explain me more about pcall?
ChunLing #5
Posted 29 December 2012 - 05:09 PM
Not really feeling like it. But the link grabie2 provided explains pretty much all there is to explain.
grabie2 #6
Posted 29 December 2012 - 09:22 PM
pcall is pretty simple: instead of calling function like that:

os.loadAPI("awesomeAPI")
you call it like that:

local ok, p1, p2, p3 = pcall(os.loadAPI, "awesomeAPI")
if not ok then
  errorMessage = p1
else
  --everything went OK
end
simple, huh?