lua-users home
lua-l archive

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


On 5/11/06, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> >
> >     int result = luaL_dofile(L, "frame.lua");
> >
>
>      You should first load you script, and then run it with
> lua_pcall(). This way you can catch errors and report them.

That's what luaL_dofile does. If result is  not 0, then the error message
is at the top of the stack and can b retrieved with lua_tostring(L,-1).
--lhf

Thanks for pointing me in the right direction, such a simple solution once you know how ;-)

For other newbee wondering about this, the follow code works just fine:

    if (luaL_dofile(L, "frame.lua")!=0)
    {
        printf("Error: %s\n",lua_tostring(L,-1));
    }