lua-users home
lua-l archive

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


>  char* strLuaInput = "a = 1 + 1;\n print(a);\n";
>  
>   lua_dostring(luaVM, strLuaInput);
>  
>What is the correct way now usin lua_load?

This is fine. If lua_dostring works for you, good. But if you are interested
in catching syntax or execution errors in the string, then luaL_loadbuffer
is your friend: call luaL_loadbuffer with the string and check the return
code. If it's not zero, then there's an error message on the of the stack.
If it's zero, there's a function on the top ready to be called.

See also http://lua-users.org/lists/lua-l/2002-12/msg00046.html .
--lhf