![]() |
Array von Delphi nach Lua
Hallo Zusammen.
Ich möchte einer Delphi-App einfache Skript hinzufügen. Lua sieht gut aus, und ich versuche es mit VeriSimpleLua. Aber ich stapele mit dem Array. Ich möchte TDictionary oder zumindest Array an Lua senden. Jede Hilfe oder Tipps sind willkommen. |
AW: Array von Delphi nach Lua
Wenn jmd braucht:
Delphi-Quellcode:
....
Dict.Add('One', '1one'); Dict.Add('Two', '2two'); Dict.Add('Three', '3three'); Lua. DoStream(Stream); PushDictionaryToLua(Lua.LuaState, Dict); // Push the dictionary to Lua lua_setglobal(Lua.LuaState, 'myDict');
Delphi-Quellcode:
procedure PushDictionaryToLua(L: lua_State; const Dict: TDictionary<string, string>);
var Pair: TPair<string, string>; tmpx, tmpy: AnsiString; begin lua_newtable(L); // Create a new table on the stack; for Pair in Dict do begin tmpx := Pair.Key; tmpy := Pair.Value; lua_pushlstring(L, PAnsiChar(tmpx), Length(tmpx)); lua_pushlstring(L, PAnsiChar(tmpy), Length(tmpy)); lua_settable(L, -3); // Set the table at the given index end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:44 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz