lua-users home
lua-l archive

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


> From: Matthias Gall

> the script looks like that
> a = 1
> b = a + 1
> write (b)
> and is read correctly into the buffer. also, the script works well with
> lua.exe or luac.exe. but calling lua_dobuffer won't work. it
> always returns
> LUA_ERRSYNTAX,


The problem is the last line.  The "write" function isn't built into the
core lua language, it's actually part of the add-on I/O library.  You must
initialize the standard libraries in your host "C" program before they can
be used (lua.exe and luac.exe do this for you).

See Section 6 of the manual for more info, but here's the basic idea:

extern "C"
{
#include <lualib.h>
}

....

lua_baselibopen(L);
lua_strlibopen(L);
lua_mathlibopen(L);
lua_iolibopen(L);