Hi all,
Thanks for accepting me!
When I'm reading a long text file with LUA, Can I use pagination for splitting output?
Here the code:
function file_exists(file)
local f = io.open(file, "rb")
if f then f:close() end
return f ~= nil
end
function lines_from(file)
if not file_exists(file) then return {} end
lines = {}
for line in io.lines(file) do
lines[#lines + 1] = line
end
return lines
end
local file = 'test.lua'
local lines = lines_from(file)
for k,v in pairs(lines) do
print('line[' .. k .. ']', v)
end
I mean...like Linux command:
$ cat filename | more
Thanks for all