Advertisement
Guest User

file

a guest
Jan 24th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. function readLines(sPath)
  2.   local file = fs.open(sPath,"r")
  3.   if file then
  4.       local tLines = {}
  5.       local sLine = file.readLine()
  6.       while sLine do
  7.         table.insert(tLines,sLine)
  8.         sLine = file.readLine()
  9.       end
  10.       file.close()
  11.       return tLines
  12.   end
  13. end
  14. function writeLines(tLines, sPath)
  15.   local file = fs.open(sPath,"a")
  16.  
  17.       for a = 1,#tLines do
  18.         file.writeLine(tLines[a])
  19.       end
  20.       file.close()
  21.  
  22. end  
  23. function Search(tLines,sKey)
  24.  tRes = {}
  25.  for a = 1,#tLines do
  26.    if string.find(tLines[a],sKey)
  27.    then
  28.    sLine = tLines[a]
  29.    table.insert(tRes,sLine)
  30.    else
  31.    
  32.    end
  33.  
  34.  end
  35.  return tRes
  36. end
  37.    
  38. function serial()
  39. tChat = file.getLines("chat1.log")
  40. download = textutils.serialize(tChat)
  41. return download
  42.  
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement