lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I want to know that is there any way through which we can call the one Lua
script inside the other script. Actually, my requirement is that I have to >
call one general script which would set my variables, preparing the system
for me and then through other scripts I am performing different different >
operations on the basis of the variables set by the first script.

In one of my Lua programs (called scandir because it scans the directory for
filenames which match the required criteria), the script invokes other
scripts with varying parms. You should be warned that this might not be a
very good way, but it works for me. Specifically, there are four versions of
"parse", namely parsePNL, parsePRE, parseFIX, and parseGPR. "dname" will
contain the appropriate suffix.

Finally, this is WinXP based, hence the "\\" instead of "\".

FYI, "table" contains the list of file names.

--
-- other Lua code
--    
    local pgm = "c:\\lua\\source\\parse" .. dname .. ".lua" 
    print("Scandir will invoke PGM = ", pgm)    
        
    for i = 1, #table do
          arg[1] = dir .. "\\" ..  table[i]
          assert(loadfile(pgm))()
          print("ScanDir processed file ==> ", dir .. "\\" .. table[i])
    end

-- 
-- additional code
--