Advertisement
Spacie

table from file and dir file list

Oct 19th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. io.write("Hello world, from ",_VERSION,"!\n")
  2. print("Hello World!")
  3. file = io.open("C:\\temp\\1.txt")
  4. -- файл содержит:
  5. -- 1 1 1
  6. -- 2 2 2
  7. -- 3 3 3
  8. local database = { }
  9. d2 = { }
  10. if file then
  11.     for line in file:lines() do
  12.         local f = line
  13.         print(f)
  14.         table.insert(d2,f) -- пишем просто строку
  15.         local n, a, e = line:match '(%S+)%s+(%S+)%s+(%S+)'
  16.         table.insert(database, { x = n, y = a, z = e }) -- пишем индексы и значения
  17.         print(n, a, e)
  18.     end
  19. end
  20. x = 3
  21. y = 3
  22. z = 3
  23. for i = 1, #database do
  24.     if string.match(database[i].x ,x) and string.match(database[i].y ,y) and string.match(database[i].z ,z) then
  25.         print("match"..i)
  26.     end
  27. --~     print(database[i].x,database[i].y,database[i].z)
  28. end
  29.  
  30. --~ for k in io.popen([[dir "C:\temp" /b]]):lines() do print(k) end --выведет список файлов
  31. --~ for dir in io.popen([[dir "C:\temp" /b /ad]]):lines() do print(dir) end -- выведет список директорий
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement