lua-users home
lua-l archive

RE: Lua Chunk Type

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


Or I guess it is more correct to say the function returned.

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

From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Leinen, Rick
Sent: Friday, August 05, 2016 1:06 PM
To: lua-l@lists.lua.org
Subject: Lua Chunk Type

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


AltStyle によって変換されたページ (->オリジナル) /