lua-users home
lua-l archive

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



I’m trying to figure out how to save the chunk returned by functions such as luaL_loadbuffer (I assume it is a pointer).  For example, if I run the follow C code, my Lua code will run just fine.


  if( luaL_loadbuffer(L, testPtr, scriptLen, "luaScript") )

    fprintf(stderr, "%s\n", lua_tostring(L, -1));

  if ( lua_pcall(L, 0, 0, 0) )

    fprintf("%s\n", lua_tostring(L, -1));


What I would like to do is save off the returned chunk on the stack so I can later push it onto the stack and run the compiled code again.  I’m sure this is simple, but I haven’t  found the solution yet.




Rick Leinen
Engineering Manager - R&D Projects, Energy Management, Controls and Automation - Tualatin
T: 503 404-5561 | C: 503 860-6305

Leviton Manufacturing Co., Inc.
20497 SW Teton Ave, Tualatin, OR 97062 |

Stay Connected with Leviton Mobile Apps: