Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- -- 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
- cyklu=1
- while true do
- local data
- data = fs.open("aaa","r")
- --zjistime pocet radku ze souboru
- local file = 'aaa'
- local lines = lines_from(file)
- print(lines)
- citac_radku = data.readLine() -- nacti radek
- if citac_radku == nil then break end
- result = {};
- for match in string.gmatch(citac_radku, "[^%s]+") do
- table.insert(result, match);
- end
- print(result[1]) -- souradnice X
- print(result[2]) -- souradnice Y
- print(result[3]) -- souradnice Z
- print(result[4]) -- item
- x = (result[1])
- y = (result[2])
- z = (result[3])
- item = (result[4])
- cyklu = cyklu + 1
- end
- print("Konec")
- -----------------------------------------------
- local open = io.open
- local function read_file(path)
- local file = open(path, "r") -- r read mode and b binary mode
- if not file then return nil end
- local content = file:read "*a" -- *a or *all reads the whole file
- file:close()
- return content
- end
- local fileContent = read_file("aaa");
- print (fileContent);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement