lua-users home
lua-l archive

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



> A simpler version could be simply this:
>
> void my_dostring(lua_State *L, const char *cmd)
> {
>     if (luaL_loadbuffer(L, cmd, strlen(cmd), cmd) ||
>         lua_pcall(L, 0, LUA_MULTRET, 0)) {
>       fprintf(stderr, "%s\n", lua_tostring(L, -1));
>       lua_pop(L, 1);
>     }
> }

This wouldn't work for me, Lua is embedded in my application and does not
use stderr, but a console within the app.

> As lhf pointed out, you don't have to call _ALERT. (Actually, lua does
> not define _ALERT anymore, so if you want to call it, you have to define
> it.)

Right.  I guess it still works because I have overriden alert in order to
re-direct error messages to my Lua console.  I have also overridden print(),
but alert does things differently to ensure errors are coloured red in the
output.  There's no reason I couldn't either push an error handler to do the
same, or modifiy your example to print it in the right place and style,
though.

Thanks!

Love, Light and Peace,
- Peter Loveday
Director of Development, eyeon Software