LF_DoFile

LuaFAR 3

LF_DoFile


int LF_DoFile (lua_State *L, const wchar_t *filename, int argc, wchar_t *argv[])

Description:

Runs Lua script filename passing it argc string arguments from argv. The script receives the arguments in UTF-8 encoding. The function returns 0 if no error occured. Otherwise, it prints error message on stderr and returns an error code.

This function can be used for testing some LuaFAR libraries (bit64, win, unicode) and functions (require, package.loadlib, etc.) from an application that is not Far plugin, for example:

    #include "luafar.h"
    int wmain (int argc, wchar_t* argv[])
    {
      int status = 0;
      if (argc >= 2) {
        lua_State *L = lua_open();
        LF_InitLuaState1(L, NULL);
        status = LF_DoFile(L, argv[1], argc-2, argv+2);
        lua_close(L);
      }
      return status;
    }