Can't answer the question about finding files, as I don't use the DOS unit at all in FPC .

On the problem of returning 20 items from a function. Its a very simple fix. Return a table instead, then you can have as many items as you want. So for example:
Code:
function MyTest()
  local i = {}
  for n=1,1000 do
    i[n]=tostring(n)
  end
  return i
end
In pascal then just call luaToVariant(L, idx) on your result type and expect to get back a variant array. It took along time to modify luaToVariant to accept variant arrays, but its been a very worth while effort