[code test. The lua files]
The function GetAlbums (param, url) {
Albums={}
Return album
}
[the Delphi code]
The function lua_GetAlbums (a, b: pAnsiChar) : pAnsiChar;
Var
Lua: TLua;
The begin
Lua:=TLua. The Create ();//create a TLua object
Luaopen_os (Lua. LuaInstance);
Luaopen_string (Lua. LuaInstance);
Luaopen_table (Lua. LuaInstance);
//luaopen_os ();
//luaopen_string ();
//luaopen_table ();
Test. The Lua Lua. DoFile (' ');//the corresponding test. The lua files
//
//if (Lua_resume (Lua, 0) & lt;> 0) then the begin//execution loaded into memory the script in the
//ShowMessage (" err ");
//end;
//
Lua_getglobal (Lua LuaInstance, 'GetAlbums');//the corresponding test. The add function of lua
Lua_pushstring (Lua LuaInstance, a);//pressed sum function need the parameters of a stack
Lua_pushstring (Lua LuaInstance, b);//pressed the needs of the sum function parameter b stack
//lua_pushnumber (Lua LuaInstance, a);//pressed sum function need the parameters of a stack
//lua_pushnumber (Lua LuaInstance, b);//pressed the needs of the sum function parameter b stack
Lua_pcall (Lua. LuaInstance, 2, 0);//the sum function call, 2 has two parameters, 1 have a return value
//Result:=integer (lua_toInteger (Lua LuaInstance, 1));
Result:=lua_tolstring (Lua LuaInstance, 1, '1');
//... By rights should also be clear stack, but no matter first
Lua. Free;
end;
The lua_tolstring here how to write a call is an error
I don't know lua_GetAlbums this function is not wrong