views:

198

answers:

1

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
Thank you, by the way do you know anything about displaying an error?
Tamir
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
Thanks alot.Working great.
Tamir