Jump to content




OS run feature help


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

#1 Boss Nomad

  • Members
  • 18 posts

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.

#2 grabie2

  • Members
  • 79 posts
  • LocationPoland

Posted 29 December 2012 - 03:19 AM

Look at that: http://www.lua.org/m....html#pdf-pcall

#3 ChunLing

  • Members
  • 2,027 posts

Posted 29 December 2012 - 03:20 AM

You can always pcall a loadstring.

#4 Boss Nomad

  • Members
  • 18 posts

Posted 29 December 2012 - 07:40 AM

There wasnt alot info about it, can someone explain me more about pcall?

#5 ChunLing

  • Members
  • 2,027 posts

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.

#6 grabie2

  • Members
  • 79 posts
  • LocationPoland

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?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users