tomtrein

Untitled

Oct 16th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. local tLines = {}
  2. local nLine = 5 -- Say we don't want line 5.'
  3. local file = fs.open( "jobs", "r" )
  4. local fileContents = file.readAll()
  5. file.close()
  6.  
  7. -- Compatibility: Lua-5.1
  8. function split(str, pat)
  9. local t = {} -- NOTE: use {n = 0} in Lua-5.0
  10. local fpat = "(.-)" .. pat
  11. local last_end = 1
  12. local s, e, cap = str:find(fpat, 1)
  13. while s do
  14. if s ~= 1 or cap ~= "" then
  15. table.insert(t,cap)
  16. end
  17. last_end = e+1
  18. s, e, cap = str:find(fpat, last_end)
  19. end
  20. if last_end <= #str then
  21. cap = str:sub(last_end)
  22. table.insert(t, cap)
  23. end
  24. return t
  25. end
  26.  
  27. tLines = split( fileContents, "n" ) -- Split the file string into a table by lines.
  28. local sFile = "" -- This will be the appended file.
  29.  
  30. for index,value in ipairs( tLines ) do
  31. if fs.exists(value) then -- If we're not on line 5.'
  32. sFile = sFile .. value .. "n" -- Read the next line in and add an end line character to it.
  33. end
  34. end
  35.  
  36. file = fs.open( "jobs", "w" )
  37. file.write( sFile ) -- Write the new contents into the file.
  38. file.close()
  39.  
  40.  
  41. local tLines = {}
  42. local nLine = 5 -- Say we don't want line 5.'
  43. local file = fs.open( "jobs", "r" )
  44. local fileContents = file.readAll()
  45. file.close()
  46.  
  47. tLines = split( fileContents, "n" ) -- Split the file string into a table by lines.
  48. local sFile = "" -- This will be the appended file.
  49.  
  50. for index,value in ipairs( tLines ) do
  51. shell.run("edit3", value)
  52. end
Advertisement
Add Comment
Please, Sign In to add comment