lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Taj,
Thanks for the post.  I did have a look at them and the problem is I'm
still at the I-use-Lua-but-I-don't-quite-get-how-it-works-stage :-)  So
let me start with a simpler question.  I want to catch lua source errors
so I think I need to use lua_pcall instead of lua_call.  lua_pcall takes
a stack index for an error handler function.  On startup I registered an
error handler function, so I'm gueesing I need to pass the index of that
function to lua_pcall?  How do I get the index?  I can use
lua_pushstring of the function name and then lua_gettable to retrieve a
function, then push parameters and call it, but how do I get the index
of the function so I can pass it to lua_pcall?
Thanks,
Brett

----- Original Message ----- 
From: "Taj Khattra" <taj.khattra@pobox.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Wednesday, November 19, 2003 1:39 PM
Subject: Re: Lua Debug Examples


> On Wed, Nov 19, 2003 at 11:48:58AM +0800, Brett Bibby wrote:
> > We're trying to implement a robust lua debugging interface and while
the
> > manual briefly explains the different mechanisms I couldn't find any
> > exmaples of how to use it.  Are there any complete examples that
show
> > how to write a pcall error function that shows how to extract the
error
> > info in C?  Also, does anybody have any reocmmendations on how to
set up
> > the hooks and callbacks?
>
> the default lua interpreter (in src/lua/lua.c) and the debug library
> (in src/lib/ldblib.c) are a useful source of examples on how to use
> lua_pcall() and the debug interface from C.
>
> -taj