#! lua-5.0.exe -- List items extracted from a text file. -- -- by Philippe Lhoste http://Phi.Lho.free.fr -- v. 1.0 -- 2003/10/19 -- Initial code local filenameIn = (arg and arg[1]) or "ScintillaDoc.html" -- If absent, use default file local filenameOut = (arg and arg[2]) or "SciList.txt" -- If absent, use default file local sciList = {} local fileOut -- Extract useful information from the given line. function ProcessLine(line) if line == nil then return nil end _, _, sci = string.find(line, [[id="(SCI_[^"]*)"]]) if sci ~= nil then table.insert(sciList, sci) end return nil end -- Output an element of the list. function OutputList(i, v) fileOut:write(" \n") end -- Process the input file. function ProcessFile() local fi = io.open(filenameIn, "r") if not fi then return false, "open " .. filenameIn end fileOut = io.open(filenameOut, "w") if not fileOut then return false, "open " .. filenameOut end -- Loop on the lines and add all SCI_ messages to the sciList table for line in fi:lines() do ProcessLine(line) end table.sort(sciList) table.foreachi(sciList, OutputList) fi:close() fileOut:close() return true, nil end result, op = ProcessFile() if not result then print("Error in operation: " .. (op or 'nil')) else print"Done!" end