Uh, Jeremy? I just tried compiling a sandbox, and it gave me about 48 errors in FPC 2.0.4 saying that "result is undefined". Did I leave something out?

luaexec.pas:
Code:
program luaexec;

{$MODE DELPHI}

uses LuaWrapper, lua, LuaUtils, SysUtils, crt;

function lua_Search(L : PLua_State) : integer; cdecl;
var
  i, n, idx : integer;
  searchResult : TSearchRec;
  path, mask: AnsiString; // You should always use AnsiStrings and not Strings
begin
  n := lua_gettop(L); // Get the number of items being passed in
  if n > 0 then
    begin
      path := luatostring(L, 1);
      if n > 1 then
        mask := luatostring(L, 2)
      else
        mask := '*.*';
    end
  else
    begin
      mask := '*.*';
      path := ExtractFilePath(ParamStr(0));
    end;
  lua_newtable(L);  // Create a new table
  idx := lua_tointeger(L, 1);
  lua_Search := 1;
  i := 1;
  if FindFirst(path + mask, faAnyFile, searchResult) = 0 then
    begin
      repeat
        lua_pushinteger(L, i);
        inc(i);
        luapushstring(path + mask);
        lua_settable(L, idx);
      until FindNext&#40;searchResult&#41; <> 0;
      FindClose&#40;searchResult&#41;;
    end;
end;

function lua_KeyPressed&#40;L &#58; PLua_State&#41; &#58; integer; cdecl;
begin
  luapushboolean&#40;L,KeyPressed&#41;;
end;

var main&#58; TLua;

BEGIN
  main &#58;= TLua.Create&#40;nil&#41;;
  main.LoadFile&#40;'main.lua'&#41;;
  main.RegisterMethod&#40;'FindFiles', @lua_Search&#41;;
  main.RegisterMethod&#40;'KeyPressed', @lua_KeyPressed&#41;;
  main.Execute;
  main.free;
END.
main.lua:
Code:
 -- MAIN.LUA
 
print&#40;"Greetings Terran!"&#41;;
while not KeyPressed&#40;&#41; do end
Should work according to what I know. FPC has always seemed picky to me though, so I never quite understood the problem with things like this. I thought result was always assumed in a function.

Errors raised:
Code:
lua.pas&#40;796,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;814,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;840,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;845,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;850,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;855,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;860,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;865,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;870,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;875,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;880,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;900,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;905,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;915,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;934,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;946,5&#41; Error&#58; Identifier not found "result"
lua.pas&#40;948,5&#41; Error&#58; Identifier not found "result"
lua.pas&#40;953,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;958,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;963,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;968,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;973,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;978,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;983,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;988,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;989,6&#41; Error&#58; Identifier not found "result"
lua.pas&#40;990,5&#41; Error&#58; Identifier not found "result"
lua.pas&#40;995,3&#41; Error&#58; Identifier not found "result"
lua.pas&#40;996,6&#41; Error&#58; Identifier not found "result"
lua.pas&#40;997,5&#41; Error&#58; Identifier not found "result"
lua.pas&#40;1026,5&#41; Error&#58; Identifier not found "result"
lua.pas&#40;1030,5&#41; Error&#58; Identifier not found "result"
lua.pas&#40;1073&#41; Fatal&#58; There were 32 errors compiling module, stopping
lua.pas&#40;5,46&#41; Fatal&#58; Compilation aborted