I'm trying to learn how to use Lua with C, so by now I want to try running a script without loading it from a file, since I don't want to be bothered with messing up with files. Can anybody tell me which functions do I need to call for executing a simple string or what ever?
+5
A:
You can use luaL_dostring to execute a script from a string.
If you need help with the basics (creating a Lua state, etc.), read part IV of Programming in Lua.
interjay
2010-01-30 21:07:12
Thank you, by the way do you know anything about displaying an error?
Tamir
2010-01-30 21:48:28
See how errors are handled in this example: http://www.lua.org/pil/24.1.htmlThat code uses `luaL_loadbuffer` and `lua_pcall` instead of `luaL_dostring`, but it should work the same way.
interjay
2010-01-30 21:57:16
Thanks alot.Working great.
Tamir
2010-01-31 19:34:53