YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

What is the use of function.pcall()
matty
#1 Posted : Saturday, September 9, 2017 11:50:07 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/12/2017(UTC)
Posts: 8

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I don't understand what functionality `function.pcall()` provides me.

If I have this C/C++ function, which I call from Squirrel.

Code:

// C/C++
static SQInteger wrap_foo(SQVM* v) {
    return sq_throwerror(v, "I did this on purpose.");
}


Code:

// Squirrel

// using function.pcall()
acorn.foo.pcall(this); // throws an error, and program exits
try { acorn.foo.pcall(this); } catch(err) { print(err); } // catches and prints error

// not using function.pcall()
acorn.foo(this); // throws an error, and program exits
try { acorn.foo(); } catch(err) { print(err); } // catches and prints error


In the above two examples, I don't see what I'm gaining from using `function.pcall()` since both cases behave exactly the same way.
Maybe, I'm just using `pcall()` incorectly; if so, can someone please explain to me the proper use?

Thank you
- Mat
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.074 seconds.