Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tLines = {}
- local nLine = 5 -- Say we don't want line 5.'
- local file = fs.open( "jobs", "r" )
- local fileContents = file.readAll()
- file.close()
- -- Compatibility: Lua-5.1
- function split(str, pat)
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- tLines = split( fileContents, "n" ) -- Split the file string into a table by lines.
- local sFile = "" -- This will be the appended file.
- for index,value in ipairs( tLines ) do
- if fs.exists(value) then -- If we're not on line 5.'
- sFile = sFile .. value .. "n" -- Read the next line in and add an end line character to it.
- end
- end
- file = fs.open( "jobs", "w" )
- file.write( sFile ) -- Write the new contents into the file.
- file.close()
- local tLines = {}
- local nLine = 5 -- Say we don't want line 5.'
- local file = fs.open( "jobs", "r" )
- local fileContents = file.readAll()
- file.close()
- tLines = split( fileContents, "n" ) -- Split the file string into a table by lines.
- local sFile = "" -- This will be the appended file.
- for index,value in ipairs( tLines ) do
- shell.run("edit3", value)
- end
Advertisement
Add Comment
Please, Sign In to add comment