.
This commit is contained in:
parent
5f611cdc46
commit
a2c5a6a128
@ -8,6 +8,36 @@ steps = 18
|
||||
-- dimensions of the matrix
|
||||
length = 6
|
||||
|
||||
|
||||
-- see if the file exists
|
||||
function file_exists(file)
|
||||
local f = io.open(file, "rb")
|
||||
if f then f:close() end
|
||||
return f ~= nil
|
||||
end
|
||||
|
||||
-- get all lines from a file, returns an empty
|
||||
-- list/table if the file does not exist
|
||||
function lines_from(file)
|
||||
if not file_exists(file) then return {} end
|
||||
local lines = {}
|
||||
for line in io.lines(file) do
|
||||
lines[#lines + 1] = line
|
||||
end
|
||||
return lines
|
||||
end
|
||||
|
||||
-- tests the functions above
|
||||
local file = 'test.lua'
|
||||
local lines = lines_from(file)
|
||||
|
||||
-- print all line numbers and their contents
|
||||
for k,v in pairs(lines) do
|
||||
print('line[' .. k .. ']', v)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local shapeFile = basic.readFileAll("/brulijam/shape0.svg")
|
||||
|
||||
print(shapeFile)
|
||||
|
Loading…
Reference in New Issue
Block a user