lua-users home
lua-l archive

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


Greetings,

 

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.

 

Thanks,

 

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
www.leviton.com | rleinen@leviton.com

Stay Connected with Leviton Mobile Apps: www.leviton.com/apps